Git Product home page Git Product logo

programming-data-structure-using-c's Introduction

Programming-Data-Structure-using-C

This repo is related with programming and data structure using C language.

Hacktoberfest 2023


Event details :

  • Hacktoberfest® is open to everyone in our global community. Whether you’re a developer, student learning to code, event host, or company of any size, you can help drive growth of open source and make positive contributions to an ever-growing community. All backgrounds and skill levels are encouraged to complete the challenge.

  • Hacktoberfest is a celebration open to everyone in our global community.

  • Pull requests can be made in any GitHub-hosted repositories/projects.

  • You can sign up anytime between October 1 and October 31.

HacktoberFest Rules :

To earn your Hacktoberfest tee or tree reward, you must register and make four valid pull requests (PRs) between October 1-31 (in any time zone). Pull requests can be made in any participating GitHub or GitLab hosted repository/project. Look for the 'hacktoberfest' topic to know if a repository/project is participating in Hacktoberfest. Pull requests must be approved by a maintainer of the repository/project to count. If a maintainer reports your pull request as spam or behavior not in line with the project’s code of conduct, you will be ineligible to participate. This year, the first 55,000 participants who successfully complete the challenge will be eligible to receive a prize.


Whether it’s your first or fiftieth pull request, there’s always more to learn! We’ve put together a few resources that can help you create quality pull requests, keep your repositories pristine, and build on your open source knowledge.



Rules To Contribute To This Repo

  • Use any language.
  • C, C++, Data Structure and Algorithms.
  • Anything valuable.

Steps For Contribution

1. Fork this repo
2. Star this repo
3. Add a file
4. commit the code
5. Make pull request

Thank You for your contributions.

programming-data-structure-using-c's People

Contributors

21rr10 avatar hactercalling avatar jacobgangwar123 avatar kkomalk avatar nida242004 avatar nihit25 avatar patelg5606 avatar pkini2002 avatar saurabhgr avatar thrivikramteja avatar toadsong8451 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

programming-data-structure-using-c's Issues

Write a C++ code to do Constructor Overloading in C++ <Open Ended>

In C++, We can have more than one constructor in a class with same name, as long as each has a different list of arguments.This concept is known as Constructor Overloading and is quite similar to function overloading.

Overloaded constructors essentially have the same name (exact name of the class) and different by number and type of arguments.
A constructor is called depending upon the number and type of arguments passed.
While creating the object, arguments must be passed to let compiler know, which constructor needs to be called.

Write a C++ Program to do Constructor in Multiple Inheritance <Open Ended>

Constructor is a class member function with the same name as the class. The main job of the constructor is to allocate memory for class objects. Constructor is automatically called when the object is created.

Multiple Inheritance:

Multiple Inheritance is a feature of C++ where a class can derive from several(two or more) base classes. The constructors of inherited classes are called in the same order in which they are inherited.

Write a Program to check whether tree is a BST

For the purposes of this challenge, we define a binary tree to be a binary search tree with the following ordering requirements:

The value of every node in a node's left subtree is less than the data value of that node.
The value of every node in a node's right subtree is greater than the data value of that node.
Given the root node of a binary tree, can you determine if it's also a binary search tree?

Complete the function in your editor below, which has parameter: a pointer to the root of a binary tree. It must return a boolean denoting whether or not the binary tree is a binary search tree. You may have to write one or more helper functions to complete this challenge.

Input Format

You are not responsible for reading any input from stdin. Hidden code stubs will assemble a binary tree and pass its root node to your function as an argument.

Constraints

Output Format

You are not responsible for printing any output to stdout. Your function must return true if the tree is a binary search tree; otherwise, it must return false. Hidden code stubs will print this result as a Yes or No answer on a new line.

Sample Input

tree

Sample Output

No

Write a Program to do Recursive digit Sum

We define super digit of an integer using the following rules:

Given an integer, we need to find the super digit of the integer.

If has only digit, then its super digit is .
Otherwise, the super digit of is equal to the super digit of the sum of the digits of .
For example, the super digit of will be calculated as:

super_digit(9875)   	9+8+7+5 = 29 
super_digit(29) 	2 + 9 = 11
super_digit(11)		1 + 1 = 2
super_digit(2)		= 2  

Example

The number is created by concatenating the string times so the initial .

superDigit(p) = superDigit(9875987598759875)
              9+8+7+5+9+8+7+5+9+8+7+5+9+8+7+5 = 116
superDigit(p) = superDigit(116)
              1+1+6 = 8
superDigit(p) = superDigit(8)

All of the digits of sum to . The digits of sum to . is only one digit, so it is the super digit.

Function Description

Complete the function superDigit in the editor below. It must return the calculated super digit as an integer.

superDigit has the following parameter(s):

string n: a string representation of an integer
int k: the times to concatenate to make
Returns

int: the super digit of repeated times
Input Format

The first line contains two space separated integers, and .

Constraints

Sample Input 0

148 3
Sample Output 0

3
Explanation 0

Here and , so .

super_digit(P) = super_digit(148148148)
= super_digit(1+4+8+1+4+8+1+4+8)
= super_digit(39)
= super_digit(3+9)
= super_digit(12)
= super_digit(1+2)
= super_digit(3)
= 3
Sample Input 1

9875 4
Sample Output 1

8
Sample Input 2

123 3
Sample Output 2

9
Explanation 2

Here and , so .

super_digit(P) = super_digit(123123123)
= super_digit(1+2+3+1+2+3+1+2+3)
= super_digit(18)
= super_digit(1+8)
= super_digit(9)
= 9

Write a program to do Grading of Students

Indiana University has the following grading policy:

Every student receives a in the inclusive range from to .
Any less than is a failing grade.
Sam is a professor at the university and likes to round each student's according to these rules:

If the difference between the and the next multiple of is less than , round up to the next multiple of .
If the value of is less than , no rounding occurs as the result will still be a failing grade.
Examples

round to (85 - 84 is less than 3)
do not round (result is less than 40)
do not round (60 - 57 is 3 or higher)
Given the initial value of for each of Sam's students, write code to automate the rounding process.

gradingStudents has the following parameter(s):

int grades[n]: the grades before rounding
Returns

int[n]: the grades after rounding as appropriate
Input Format

The first line contains a single integer, , the number of students.
Each line of the subsequent lines contains a single integer, .

Constraints

Sample Input 0

4
73
67
38
33
Sample Output 0

75
67
40
33
Explanation 0

Student received a , and the next multiple of from is . Since , the student's grade is rounded to .
Student received a , and the next multiple of from is . Since , the grade will not be modified and the student's final grade is .
Student received a , and the next multiple of from is . Since , the student's grade will be rounded to .
Student received a grade below , so the grade will not be modified and the student's final grade is .

Write a C++ code to do Nested list in C++ STL <Open Ended>

[list in STL] is used to represent a linked list in C++. How to create a nested list. We are given n lists, we need to create a list of n lists. Examples:

Input : Number of lists: 2
1st list: {1 2}
2nd list: {3 4 5 6}
Output :
[
[ 1 2 ]
[ 3 4 5 6 ]
]

Input : Number of lists: 3
1st list : {0 1}
2nd list : {1 2 3}
3rd list : {2 3 4 5}
Output :
[
[ 0 1 ]
[ 1 2 3 ]
[ 2 3 4 5 ]
]

Write a program to do Binary Search LCA

You are given pointer to the root of the binary search tree and two values and . You need to return the lowest common ancestor (LCA) of and in the binary search tree.

image
In the diagram above, the lowest common ancestor of the nodes and is the node . Node is the lowest node which has nodes and as descendants.

Function Description

Complete the function lca in the editor below. It should return a pointer to the lowest common ancestor node of the two values given.

lca has the following parameters:

  • root: a pointer to the root node of a binary search tree
  • v1: a node.data value
  • v2: a node.data value

Input Format

The first line contains an integer, , the number of nodes in the tree.
The second line contains space-separated integers representing values.
The third line contains two space-separated integers, and .

To use the test data, you will have to create the binary search tree yourself. Here on the platform, the tree will be created for you.

Constraints

The tree will contain nodes with data equal to and .

Output Format

Return the a pointer to the node that is the lowest common ancestor of and .

Sample Input

6
4 2 3 1 7 6
1 7
image

and .

Sample Output

[reference to node 4]

Explanation

LCA of and is , the root in this case.
Return a pointer to the node.

Write a C++ code to do Function Overloading and Return Type in C++ <Open Ended>

Function overloading is possible in C++ and Java but only if the functions must differ from each other by the types and the number of arguments in the argument list. However, functions can not be overloaded if they differ only in the return type.

Why is Function overloading not possible with different return types?

Function overloading comes under the compile-time polymorphism. During compilation, the function signature is checked. So, functions can be overloaded, if the signatures are not the same. The return type of a function has no effect on function overloading, therefore the same function signature with different return type will not be overloaded.

Example: if there are two functions: int sum() and float sum(), these two will generate a compile-time error as function overloading is not possible here.

Write a C++ code to do Operator Overloading in C++ <Open Ended>

Operator overloading is a compile-time polymorphism. It is an idea of giving special meaning to an existing operator in C++ without changing its original meaning.

In C++, we can make operators work for user-defined classes. This means C++ has the ability to provide the operators with a special meaning for a data type, this ability is known as operator overloading. For example, we can overload an operator ‘+’ in a class like String so that we can concatenate two strings by just using +. Other example classes where arithmetic operators may be overloaded are Complex Numbers, Fractional Numbers, Big integers, etc.

Example:

int a;
float b,sum;
sum = a + b;
Here, variables “a” and “b” are of types “int” and “float”, which are built-in data types. Hence the addition operator ‘+’ can easily add the contents of “a” and “b”. This is because the addition operator “+” is predefined to add variables of built-in data type only.

Write a C++ code to do Function Overloading in C++ <Open Ended>

Function overloading is a feature of object-oriented programming where two or more functions can have the same name but different parameters. When a function name is overloaded with different jobs it is called Function Overloading. In Function Overloading “Function” name should be the same and the arguments should be different. Function overloading can be considered as an example of a [polymorphism] feature in C++.

If multiple functions having same name but parameters of the functions should be different is known as Function Overloading.
If we have to perform only one operation and having same name of the functions increases the readability of the program.
Suppose you have to perform addition of the given numbers but there can be any number of arguments, if you write the function such as a(int,int) for two parameters, and b(int,int,int) for three parameters then it may be difficult for you to understand the behavior of the function because its name differs.

The parameters should follow any one or more than one of the following conditions for Function overloading:

Parameters should have a different type

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.