C Programming and Data Structures: Unit III: a. Linear Data Structures - List

Two Marks Questions with Answers

Linear Data Structures - List | C Programming and Data Structures

C Programming and Data Structures: Unit III: a. Linear Data Structures - List : Two Marks Questions with Answers

Two Marks Questions with Answers


Q. 1 Explain the term data structure.

Ans. : The data structure can be defined as the collection of elements and all the possible operations which are required for those set of elements. Formally data structure can be defined as a data structure is a set of domains D, a set of functions F, and a set of axioms A. This triple (D, F, A) denotes the data structure d.

 

Q. 2 What do you mean by non linear data structure? Give examples.

Ans. : The non linear data structure is the kind of data structure in which the data may be arranged in hierarchical fashion. For example - Trees and graphs.

 

Q. 3 What do you mean by linear data structure ? Give example.

Ans. : The linear data structure is a kind of data structure in which the data is linearly arranged. For example - Stacks, queues, linked list.

 

Q. 4 Enlist the various operations that can be performed on data structure.

Ans. : Various operations that can be performed on the data structure are -

1. Create

2. Insertion of element

3. Deletion of element

4. Searching for the desired element

5. Sorting the elements in the data structure.

6. Reversing the list of elements.

 

Q. 5 What is abstract data type? What are all not concerned in an ADT ? AU: Dec.-19

Ans. : The abstract data type is a triple of D i.e. set of axioms, F-set of functions and A- Axioms in which only what is to be done is mentioned but how is to be done is not mentioned. Thus ADT is not concerned with implementation details.

 

Q. 6.  List out the areas in which data structures are applied extensively.

Ans. : Following are the areas in which the data structures are applied extensively.

1. Operating system - The data structures like priority queues are used for scheduling the jobs in the operating system.

2. Compiler design - The tree data structure is used in parsing the source program. inil vlduob Stack data structure is used in handling the recursive calls.

3. Database management system The file data structure is used in database management systems. Sorting and searching techniques can be applied on these data in the file.

 4. Numerical analysis package - The array is used to perform the numerical analysis ble on the given set of data.

 5. Graphics - The array and linked list are useful in graphics applications.

6. Artificial intelligence - The graph and trees are used for the applications like building expression trees, game playing.

7. Networking - The graph is used for finding the shortest path length between any two computers that are connected in a LAN.

8. Simulation - The queue is used for simulation and modeling.

 

Q. 7 What is a linked list ? 10 AU: Dec.-19

Ans. : A linked list is a set of nodes where each node has two fields 'data' and 'link'. The data field is used to store actual piece of information and link field is used to store address of next node.

 

Q. 8 Write down the steps to modify a node in linked lists.

 Ans. :

1. Enter the position of the node which is to be modified.

 2. Enter the new value for the node to be modified.

3. Search the corresponding node in the linked list.

4. Replace the original value of that node by a new value.

 5. Display the message as "The node is modified".

 

Q. 9 State the properties of LIST abstract data type with suitable example.

Ans. Various properties of LIST abstract data type are –

1. It is linear data structure in which the elements are arranged adjacent to each other. elinteb neilstrsms.

2. It allows to store single variable polynomial.

3. If the LIST is implemented using dynamic memory then it is called linked list.

Example of LIST are - Stacks, Queues, Linked List.

 

Q. 10 State the advantages of circular lists over doubly linked list.

Ans. In circular list the next pointer of last node points to head node, whereas in doubly linked list each node has two pointers: One previous pointer and another is next pointer. The main advantage of circular list over doubly linked list is that with the help of single pointer field we can access head node quickly. Hence some amount of memory get saved because in circular list only one pointer field is reserved.

 

Q. 11 What are the advantages of doubly linked list over singly linked list?

 Ans. : The doubly linked list has two pointer fields. One field is previous link field and another is next link field.

Because of these two pointer fields we can access any node efficiently whereas in singly linked list only one pointer field is there which stores forward pointer, which makes accessing of any node difficult one.

 

 Q. 12 What is the advantage of linked list over arrays ? AU: May-19

 Ans. : The linked list makes use of the dynamic memory allocation. Hence the user can allocate or de allocate the memory as per his requirements. On the other hand, the array makes use of the static memory location. Hence there are chances of wastage of the memory or shortage of memory for allocation.

Q. 13 What is circular linked list ? AU: Dec.-14, May-16

Ans. The circular linked list is a kind of linked list in which the last node is connected to the first node or head node of the linked list.

Refer section 3.6.

 

Q. 14 What is the basic purpose of header of the linked list?

Ans. : The header node is the very first node of the linked list. Sometimes a dummy value such as -999 is stored in the data field of header node. Refer Fig. 3.10.1.


This node is useful for getting the starting address of the linked list. As there is only a forward link present in the linked list, for accessing the entire linked list it is necessary to obtain the starting address of the linked list.

 

Q. 15 What is advantage of an ADT ? AU: May-14, Dec.-18

Ans. : The advantages of ADT are

1. Change: The implementation of the ADT can be changed without making changes bruin the client program that uses the ADT.

2. Understandability: ADT specifies what is to be done and does not specify the implementation details. Hence code becomes easy to understand due to ADT.

3. Reusability: The ADT can be reused by some program in future.

4. Flexibility: Different implementations are possible for the same ADT.

 

Q. 16 Should arrays of linked lists be used for the following type of applications. Justify your Answer.

a) Many search operations in sorted list.

b) Many search operations in unsorted list. AU: May-14

Ans. :

a) If the list is sorted then using linked list the desired element can be searched, simply by moving forward using 'next' pointer.

b) If a list is not sorted then using arrays the desired element can be searched. The arrays facilitates the access to random element.

 

Q. 17 What are abstract data type? AU: Dec.-14

OR Define ADT  AU: May-15

Ans. : Refer Q. 5.

 

Q. 18 What is static linked list? State any two applications of it. AU: May-15

Ans. The linked list structure which can be represented using arrays is called static linked list.

1. It is easy to implement, hence for creation of small databases, it is useful.

2. The searching of any record is efficient, hence the applications in which the record need to be searched quickly, the static linked lists are used.

 

Q. 19 Write syntax of calloc() and relloc() and mention its applications in the linked list AU: May-15

Ans. : calloc() is for allocating the required amount of memory. The syntax is void *calloc(size_t nitems, size_t size)

This function returns the pointer to the allocated memory. The calloc function is just similar to malloc but it initializes the allocated memory to zero and malloc does not.

The realloc() function modifies allocated memory size by malloc() and calloc() functions to new size. The syntax is

void *realloc (void *ptr, size_t size)

If insufficient memory exists then to expand the memory block, realloc() is used.

 

Q. 20 What are the disadvantages of linked list over arrays. AU: Dec.-18

Ans. 1) In linked list, we can access elements in sequence. So it is very difficult and time consuming to access element randomly.

2) Some amount of memory gets wasted in storing the next node's address in each nodes.

 

C Programming and Data Structures: Unit III: a. Linear Data Structures - List : Tag: : Linear Data Structures - List | C Programming and Data Structures - Two Marks Questions with Answers