Page 61 - DCAP605_ADVANCED_DATA_STRUCTURE_AND_ALGORITHMS
P. 61
Advanced Data Structure and Algorithms
Notes 2.16 Review Questions
1. Write a C program to sort the elements of a linked list.
2. Why are linked list better than arrays? Compare giving examples.
3. Create a linked list and write programs to:
(a) Insert a node at the nth position where n is accepted as an input from the keyboard.
(b) Delete a node from the nth position where n is accepted as an input from the
keyboard.
(c) Shift the node at the nth position to the position p where n and p are accepted as
inputs from the keyboard.
4. Write a program for building of an element of the circular linked list.
5. Describe the method of inserting a node using recursive program.
6. Write a C program to merge two given lists A and B to form C in the following manner:
The first element of C is the first element of A and the second element of C is the fi rst
element of B. The second elements of A and B become the third and fourth elements of C,
and so on. If either A or B gets exhausted, the remaining elements of the other are to be
copied to C.
7. Write a C program to transform a circular list into a chain.
8. Describe ADT of singly linked lists.
9. Write remove for the (second) implementation of simply linked lists that remembers the
last-used position.
10. Prepare a collection of files containing the declarations for a contiguous list and all the
functions for list processing.
Answers: Self Assessment
1. (b) 2. (a)
3. (c) 4. (d)
5. Dynamic
6. An element of the list, A link or address of another node
7. Insert 8. Linked list
9. False 10. False
11. False
2.17 Further Readings
Books Brian W. Kernighan and Dennis M. Ritchie, The C Programming Language, Prentice
Hall, 1988.
Data Structures and Algorithms; Shi-Kuo Chang; World Scientifi c.
56 LOVELY PROFESSIONAL UNIVERSITY