DEPARTMENT OF
ELECTRONICS AND COMMUNICATION ENGINEERING
EC8381 - FUNDAMENTALS OF DATA STRUCTURES IN C
--- Content provided by FirstRanker.com ---
III SEMESTER - R 2017LABORATORY MANUAL
Name :
Register No. :
Section :
--- Content provided by FirstRanker.com ---
VISION
is committed to provide highly disciplined, conscientious and enterprising professionals conforming to global standards through value based quality education and training.
MISSION
- To provide competent technical manpower capable of meeting requirements of the industry
- To contribute to the promotion of Academic Excellence in pursuit of Technical Education at different levels
- To train the students to sell his brawn and brain to the highest bidder but to never put a price tag on heart and soul
--- Content provided by FirstRanker.com ---
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
VISION
To impart professional education integrated with human values to the younger generation, so as to shape them as proficient and dedicated engineers, capable of providing comprehensive solutions to the challenges in deploying technology for the service of humanity
--- Content provided by FirstRanker.com ---
MISSION
- To educate the students with the state-of-art technologies to meet the growing challenges of the electronics industry
- To carry out research through continuous interaction with research institutes and industry, on advances in communication systems
- To provide the students with strong ground rules to facilitate them for systematic learning, innovation and ethical practices
--- Content provided by FirstRanker.com ---
PROGRAMME EDUCATIONAL OBJECTIVES (PEOS)
- Fundamentals
To impart students with fundamental knowledge in Mathematics, Science and fundamentals of Engineering that will would them to be successful professionals
- Core Competence
To provide students with sound knowledge in engineering and experimental skills to identify complex software problems in industry and to develop practical solution for them
- Breadth
To provide relevant training and experience to bridge the gap between theory and practice this enables to find solutions for real time problem in industry and organization and to design products requiring interdisciplinary skills
- Professionalism skills
To bestow students with adequate training and provide opportunities to work as team that will build up their communication skills, individual leadership and supportive qualities and to develop them to adapt and work in ever changing technologies
- Lifelong Learning
To develop the ability of students to establish themselves as professionals in Computer Science and Engineering and to create awareness about the need for lifelong learning and pursuing advanced degrees
--- Content provided by FirstRanker.com ---
--- Content provided by FirstRanker.com ---
PROGRAMME OUTCOMES (POS)
- To apply basic knowledge of Mathematics, Science and engineering fundamentals in Computer Science and Engineering field
- To design and conduct experiments as well as to analyze and interpret and apply the same in the career
- To design and develop innovative and creative software applications
- To understand a complex real world problems and develop an efficient practical solutions
- To create, select and apply appropriate technique, resources, modern engineering and IT tools
- To understand their roles as professionals and give the best to the society
- To develop a system that will meet expected need with realistic constraints such as economical, environmental, social, political, ethical, safe and sustainable
- To communicate effectively and make others understand exactly what they are trying to convey in both verbal and written forms
- To engage lifelong learning and exhibit their technical skills
- To develop and manage projects in multidisciplinary environments
--- Content provided by FirstRanker.com ---
--- Content provided by FirstRanker.com ---
EC8381 - FUNDAMENTALS OF DATA STRUCTURES IN C SYLLABUS
--- Content provided by FirstRanker.com ---
COURSE OBJECTIVES
- To understand and implement basic data structures using C
- To apply linear and non-linear data structures in problem solving.
- To learn to implement functions and recursive functions by means of data structures
- To implement searching and sorting algorithms
--- Content provided by FirstRanker.com ---
LIST OF EXPERIMENTS:
- Basic C Programs – looping, data manipulations, arrays
- Programs using strings – string function implementation
- Programs using structures and pointers
- Programs involving dynamic memory allocations
- Array implementation of stacks and queues
- Linked list implementation of stacks and queues
- Application of Stacks and Queues
- Implementation of Trees, Tree Traversals
- Implementation of Binary Search trees
- Implementation of Linear search and binary search
- Implementation Insertion sort, Bubble sort, Quick sort and Merge Sort
- Implementation Hash functions, collision resolution technique
--- Content provided by FirstRanker.com ---
--- Content provided by FirstRanker.com ---
COURSE OUTCOMES
--- Content provided by FirstRanker.com ---
- To Write basic and advanced programs in c.
- To Implement functions and recursive functions in c.
- To Implement data structures using c.
- To choose appropriate sorting algorithm for an application and implement it in a modularized way.
--- Content provided by FirstRanker.com ---
EC8381 - FUNDAMENTALS OF DATA STRUCTURES IN C SYLLABUS
CONTENTS
Sl. No. | Name of the Experiment | Page No. |
---|---|---|
1 | Basic C Programs – looping, data manipulations, arrays | 7 |
2 | Programs using strings – string function implementation | 13 |
3 | Programs using structures and pointers | 15 |
4 | Programs involving dynamic memory allocations | 20 |
5 | Array implementation of stacks and queues | 22 |
6 | Linked list implementation of stacks and queues | 29 |
7 | Application of Stacks and Queues | 35 |
8 | Implementation of Trees, Tree Traversals | 39 |
9 | Implementation of Binary Search trees | 41 |
10 | Implementation of Linear search and binary search | 46 |
11 | Implementation Insertion sort, Bubble sort, Quick sort and Merge Sort | 50 |
12 | Implementation Hash functions, collision resolution technique | 58 |
EXPT. NO. 1a BASIC C PROGRAM – LOOPING
Aim:
--- Content provided by FirstRanker.com ---
To write a C program to calculate the sum of first n natural numbers using for loop statements
Software requirements:
C compiler
Hardware requirements:
Server with supporting 30 terminals
--- Content provided by FirstRanker.com ---
Algorithm :
- Start the program.
- Read the variables.
- The initialization statement is executed.
- The test expression is evaluated, if it is false for loop is terminated, test expression is true (nonzero), codes inside the body of loop is executed and the update expression is updated.
- This process repeats until the test expression is false.
- Stop the program.
--- Content provided by FirstRanker.com ---
Output
Enter a positive integer: 10
--- Content provided by FirstRanker.com ---
Sum = 55
Result:
Thus the program to find the sum of n natural numbers was executed successfully.
EXP 1 b. BASIC C PROGRAM – DATA MANIPULATIONS
--- Content provided by FirstRanker.com ---
Aim:
To write a C program for data manipulations using the bitwise operators
Software requirements:
C compiler
Hardware requirements:
--- Content provided by FirstRanker.com ---
Server with supporting 30 terminals
Algorithm :
- Start the program.
- Declare the variables.
- Use the required bitwise operators for the given input.
- Display the result.
- Stop the program.
--- Content provided by FirstRanker.com ---
Sample Output :
A = 10
--- Content provided by FirstRanker.com ---
B = 25Bitwise AND operator & = 8
A = 10
B = 25
Bitwise OR operator | = 29
--- Content provided by FirstRanker.com ---
A= 10
B = 25
Bitwise XOR (exclusive OR) operator ^ = 21
complement = ~35
complement = ~-12
--- Content provided by FirstRanker.com ---
complement = -36
Output = 11
Shift Operator (>> and <<)
Num = 212
Right Shift by 0: 212
--- Content provided by FirstRanker.com ---
Right Shift by 1: 106Right Shift by 2: 53
Left Shift by 0: 212
Left Shift by 1: 424
Left Shift by 2: 848
--- Content provided by FirstRanker.com ---
Result:
Thus the program for data manipulations using the bitwise operators is executed successfully.
EXP 1 c BASIC C PROGRAM – ARRAYS
Aim:
--- Content provided by FirstRanker.com ---
To write a C program using Arrays
Software requirements:
C compiler
Hardware requirements:
Server with supporting 30 terminals
--- Content provided by FirstRanker.com ---
Algorithm :
- Start the program.
- Declare the array and the variables required for the program.
- Get the values.
- Perform the operation based on the program inputs.
- Display the output.
- Stop the program.
--- Content provided by FirstRanker.com ---
Sample Output :
Enter n: 5
--- Content provided by FirstRanker.com ---
Enter number1: 45Enter number2: 35
Enter number3: 38
Enter number4: 31
Enter number5: 49
--- Content provided by FirstRanker.com ---
Average = 39
Result:
Thus the program using arrays is executed successfully.
Outcome:
Thus the basic c programs for looping, Data manipulations and arrays is attained.
--- Content provided by FirstRanker.com ---
- C language is used to creating computer application
- Used in writing embedded software
- Firmware for various electronics ,industrial product which uses micro controller
- Developing verifications of software code,simulator.
VIVA - VOCE
--- Content provided by FirstRanker.com ---
- What is Decision making and Branching?
- What are all the different types of control flow statements?
- Mention the different types of looping statements.
- What is the difference between while and do while loop statement?
- What is an operator?
- Mention the bitwise operators.
- What is an array ?
- What is the use of array?
- What is multi dimensional array ?
- How to access the elements in the array.
--- Content provided by FirstRanker.com ---
--- Content provided by FirstRanker.com ---
EXP NO 2: PROGRAMS USING STRINGS FUNCTION
AIM:
To write a c program to perform string manipulation function.
Software requirements:
--- Content provided by FirstRanker.com ---
C compiler
Hardware requirements:
Server with supporting 30 terminals
Algorithm :
- Start the program.
- Declare the variables.
- Get the string by using gets() function.
- Call the required string manipulation function.
- Display the results by using the puts() function.
--- Content provided by FirstRanker.com ---
--- Content provided by FirstRanker.com ---
Sample Output :
Enter string: String
Length of string = 6
Result:
Thus the program for string manipulation is executed successfully.
--- Content provided by FirstRanker.com ---
Outcome:
Thus the programs using strings- string function implementation is attained.
Applications:
- String are used in spell checker, spam filter, intrusion detection
VIVA - VOCE
--- Content provided by FirstRanker.com ---
- What is a function ?
- Mention the types of function.
- What is a character?
- What is a string ?
- Difference between character and string.
- What are the different types of string handling functions are available.
- Which header file is to be included while using the string functions.
- How to declare a string and character?
--- Content provided by FirstRanker.com ---
EXP NO 3 a: PROGRAMS USING POINTERS
--- Content provided by FirstRanker.com ---
Aim:
To write a c program to perform swapping operation using pointers.
Software requirements:
C compiler
Hardware requirements:
--- Content provided by FirstRanker.com ---
Server with supporting 30 terminals
Algorithm :
- Start the program.
- Declare the pointer variables.
- Initialise the pointer variable with an appropriate address.
- If the content of the address stored in the pointer is required, the indirection operator* is used to obtain the value.
- Stop the program.
--- Content provided by FirstRanker.com ---
Sample Output :
Before Swapping : A = 10 B = 20
--- Content provided by FirstRanker.com ---
After Swapping: A = 20 B = 10
Result:
Thus the program to swap two numbers using pointers is executed successfully.
EXP NO 3 b: PROGRAMS USING STRUCTURES
--- Content provided by FirstRanker.com ---
Aim:
To write a c program using structures.
Software Requirements:
C compiler
Hardware Requirements:
--- Content provided by FirstRanker.com ---
Server with supporting 30 terminals
Algorithm :
- Start the program.
- Declare the structure and mention the structure variables inside the structure.
- In the main program access the member of the structure using the dot operator.
- Call the required functions inside the main function.
- Display the output.
- Stop the program.
--- Content provided by FirstRanker.com ---
Sample Output :
--- Content provided by FirstRanker.com ---
Enter No. of Employees : 2
Enter Employee Details
Enter Employee Id : 436
Enter Employee Name :Gopal
Enter Basic Salary : 10000
--- Content provided by FirstRanker.com ---
Enter Employee Details
Enter Employee Id : 463
Enter Employee Name :Rajesh
Enter Basic Salary : 22000
XYZ & Co. Payroll
--- Content provided by FirstRanker.com ---
Empld | Name | Basic | HRA | DA | IT | Gross | Net Pay |
---|---|---|---|---|---|---|---|
436 | Gopal | 10000 | 200.00 | 100.00 | 500.00 | 10300.00 | 9800.00 |
463 | Rajesh | 22000 | 440.00 | 220.00 | 1100.00 | 22660.00 | 21560.00 |
Result:
Thus the program using structure is executed successfully.
Outcome:
Thus the programs using structures and pointers is attained.
Applications:
--- Content provided by FirstRanker.com ---
- The C pointer are used to track read /write position in files in Linux/Unix OS.
VIVA - VOCE
- What is meant by pointers?
- What is meant by structure?
- What is the advantage of structure?
- What is meant by address operator?
--- Content provided by FirstRanker.com ---
- What are the usages of pointers?
- Why you need pointers in C?
- What is meant by referencing operator?
- What are the ways to declare the structure?
- What is meant by structure operator and arrow operator?
- How to pass function to pointers?
--- Content provided by FirstRanker.com ---
Expt. No. 4 PROGRAMS INVOLVING DYNAMIC MEMORY ALLOCATION
--- Content provided by FirstRanker.com ---
Aim:
To write a c program to perform dynamic memory allocation.
Software requirements:
C compiler
Hardware requirements:
--- Content provided by FirstRanker.com ---
Server with supporting 30 terminals
Algorthim:
- Start the program.
- Include the required header file for using the memory allocation function.
- Declare the required variables for the program.
- Call the required Dynamic Memory Allocation function depending upon the program.
- Display the result.
- Stop the program.
--- Content provided by FirstRanker.com ---
Sample Output :
--- Content provided by FirstRanker.com ---
Enter integer value: 100
Enter character value: x
Enter float value: 123.45
Inputted value are: 100, x, 123.45
Result:
--- Content provided by FirstRanker.com ---
Thus the program to perform dynamic memory allocation is executed successfully.
Outcome:
Thus the programs involving dynamic memory allocations are attained.
Applications:
The memory allocation concepts are used in operating systems present in embedded software.
--- Content provided by FirstRanker.com ---
- What is memory allocation?
VIVA - VOCE
- What is meant by dynamic memory allocation?
- Differentiate static memory allocation from dynamic memory allocation?
- Give some examples for memory allocation?
- What is the syntax for malloc()?
- What is difference between malloc() and realloc()?
- What is the function of calloc()?
- What is meant by free() and what is the purpose of using free() function?
- What is the significance of calloc()?
- What is syntax for calloc()?
--- Content provided by FirstRanker.com ---
--- Content provided by FirstRanker.com ---
Expt. No. 5 a ARRAY IMPLEMENTATION OF STACK
Aim:
To write a C program to perform array implementation of stack.
--- Content provided by FirstRanker.com ---
Software Requirements:
C compiler
Hardware Requirements:
Server with supporting 30 terminals
Algorithm:
--- Content provided by FirstRanker.com ---
- Start the program.
- Include all the header files which are used in the program and define a constant 'SIZE' with specific value.
- Declare all the functions used in stack implementation.
- Create a one dimensional array with fixed size (int stack[SIZE])
- Define a integer variable 'top' and initialize with '-1'. (int top = -1)
- In main method display menu with list of operations and make suitable function calls to perform operation selected by the user on the stack.
--- Content provided by FirstRanker.com ---
PUSH OPERATION
- Check whether stack is FULL. (top == SIZE-1)
- If it is FULL, then display "Stack is FULL!!! Insertion is not possible!!!" and terminate the function.
- If it is NOT FULL, then increment top value by one (top++) and set stack[top] to value (stack[top] = value).
--- Content provided by FirstRanker.com ---
POP OPERATION
- Check whether stack is EMPTY. (top == -1)
- If it is EMPTY, then display "Stack is EMPTY!!! Deletion is not possible!!!" and terminate the function.
- If it is NOT EMPTY, then delete stack[top] and decrement top value by one (top--)
--- Content provided by FirstRanker.com ---
DISPLAY
- Check whether stack is EMPTY. (top == -1)
- If it is EMPTY, then display "Stack is EMPTY!!!" and terminate the function.
- If it is NOT EMPTY, then define a variable 'i' and initialize with top. Display stack[i] value and decrement i value by one (i--).
- Repeat above step until i value becomes '0'.
--- Content provided by FirstRanker.com ---
Sample Output :
STACK OPERATION
1.PUSH 2.POP 3.VIEW 4.QUIT Enter Choice : 1
Enter Stack element: 12
--- Content provided by FirstRanker.com ---
STACK OPERATION
1.PUSH 2.POP 3.VIEW 4.QUIT Enter Choice : 1
Enter Stack element: 23
STACK OPERATION
.PUSH 2.POP 3.VIEW 4.QUIT Enter Choice: 1
--- Content provided by FirstRanker.com ---
Enter Stack element: 34STACK OPERATION
1.PUSH 2.POP 3.VIEW 4.QUIT
Enter Choice: 1
Enter Stack element: 45
--- Content provided by FirstRanker.com ---
STACK OPERATION1.PUSH 2.POP 3.VIEW 4.QUIT
Enter Choice: 3
Top--> 45 34 23 12
STACK OPERATION
--- Content provided by FirstRanker.com ---
1.PUSH 2.POP 3.VIEW 4.QUITEnter Choice: 2
Popped element is 45
STACK OPERATION
1.PUSH 2.POP 3.VIEW 4.QUIT
--- Content provided by FirstRanker.com ---
Enter Choice : 3Top--> 34 23 12
STACK OPERATION
1.PUSH 2.POP 3.VIEW 4.QUIT
Enter Choice: 4
--- Content provided by FirstRanker.com ---
Result :
Thus the program for array implementation of stack is executed successfully.
Expt. No. 5 b ARRAY IMPLEMENTATION OF QUEUE
Aim:
--- Content provided by FirstRanker.com ---
To write a C program to perform array implementation of queue.
Software Requirements:
C compiler
Hardware Requirements:
Server with supporting 30 terminals
--- Content provided by FirstRanker.com ---
Algorithm :
- Start the program.
- Include all the header files which are used in the program and define a constant 'SIZE' with specific value.
- Declare all the user defined functions which are used in queue implementation.
- Create a one dimensional array with above defined SIZE (int queue[SIZE])
- Define two integer variables 'front' and 'rear' and initialize both with '-1'. (int front = -1, rear = -1)
- Then implement main method by displaying menu of operations list and make suitable function calls to perform operation selected by the user on queue.
--- Content provided by FirstRanker.com ---
ENQUEUE OPERATION
- Check whether queue is FULL. (rear == SIZE-1)
- If it is FULL, then display "Queue is FULL!!! Insertion is not possible!!!" and terminate the function.
- If it is NOT FULL, then increment rear value by one (rear++) and set queue[rear] = value.
--- Content provided by FirstRanker.com ---
DEQUEUE OPERATION
- Check whether queue is EMPTY. (front == rear)
- If it is EMPTY, then display "Queue is EMPTY!!! Deletion is not possible!!!" and terminate the function.
- If it is NOT EMPTY, then increment the front value by one (front ++). Then display queue[front] as deleted element. Then check whether both front and rear are equal (front == rear), if it TRUE, then set both front and rear to '-1' (front = rear = -1).
--- Content provided by FirstRanker.com ---
DISPLAY OPERATION
- Check whether queue is EMPTY. (front == rear)
- If it is EMPTY, then display "Queue is EMPTY!!!" and terminate the function.
- If it is NOT EMPTY, then define an integer variable 'i' and set 'i = front+1'.
- Display 'queue[i]' value and increment 'i' value by one (i++). Repeat the same until 'i' value is equal to rear (i <= rear)
--- Content provided by FirstRanker.com ---
Sample Output :
QUEUE OPERATION
1.INSERT 2.DELETE 3.VIEW 4.QUIT Enter Choice : 1
--- Content provided by FirstRanker.com ---
Enter element to be inserted: 12QUEUE OPERATION
1.INSERT 2.DELETE 3.VIEW 4.QUIT Enter Choice : 1
Enter element to be inserted: 23
QUEUE OPERATION
--- Content provided by FirstRanker.com ---
1.INSERT 2.DELETE 3.VIEW 4.QUIT Enter Choice : 1Enter element to be inserted: 34
QUEUE OPERATION
1.INSERT 2.DELETE 3.VIEW 4.QUIT Enter Choice : 1
Enter element to be inserted: 45
--- Content provided by FirstRanker.com ---
QUEUE OPERATION
1.INSERT 2.DELETE 3.VIEW 4.QUIT Enter Choice : 1
Enter element to be inserted: 56
QUEUE OPERATION
1.INSERT 2.DELETE 3.VIEW 4.QUIT Enter Choice : 1
--- Content provided by FirstRanker.com ---
Queue FullQUEUE OPERATION
1.INSERT 2.DELETE 3.VIEW 4.QUIT Enter Choice : 3
Front--> 12 23 34 45 56 <--Rear
--- Content provided by FirstRanker.com ---
Result :
Thus the program for array implementation of Queue is executed successfully.
Outcome:
Thus the program for array implementation of stack and queue is attained.
VIVA - VOCE
--- Content provided by FirstRanker.com ---
- What is meant by data structure?
- What are the types of data structure?
- What is meant by stack?
- What is meant by queue?
- State the working principle of stack and queue?
- What is difference between stack and queue?
- What are the function of stack and queue?
- What is the task of push and pop()?
- Give some application of stack and queue?
- What is stack overflow?
--- Content provided by FirstRanker.com ---
--- Content provided by FirstRanker.com ---
Expt. No. 6 a LINKED LIST IMPLEMENTATION OF STACK
Aim:
To write a C program to perform Linked List implementation of stack.
Software Requirements:
--- Content provided by FirstRanker.com ---
C compiler
Hardware Requirements:
Server with supporting 30 terminals
Algorithm :
- Start the program.
- Include all the header files which are used in the program. And declare all the user defined functions.
- Define a 'Node' structure with two members data and next.
- Define a Node pointer 'top'
This download link is referred from the post: Anna University B.Tech Lab Manual
--- Content provided by FirstRanker.com ---
--- Content provided by FirstRanker.com ---