Unit summary

  • A linked list is a chain of nodes, each holding data and a pointer to the next node, with dynamic size but no direct access.
  • Singly linked lists support traversal, search, insertion and deletion by changing pointers.
  • Doubly linked lists add prev pointers, and circular lists link the last node back to the first.
  • Polynomials are stored as lists of (coefficient, exponent) terms and added like merging sorted lists.
  • Hashing maps keys to table slots with a hash function, giving O(1) average operations.
  • Collisions are resolved by open addressing (linear, quadratic, double hashing) or by chaining.

Glossary

Term Meaning
Chaining Keeping a list of items in each slot.
Circular linked list A list whose last node points to the first.
Collision Two keys mapped to one slot.
Doubly linked list A list with prev and next pointers.
Hash function A function giving the slot for a key.
Hash table A table indexed by hash values.
Hashing Mapping keys to table positions.
HEAD The pointer to the first node.
Linear probing Trying the next slots in turn.
Linked list A chain of nodes joined by pointers.
Load factor The ratio of items to slots.
malloc A C function that allocates memory at run time.
Node A unit holding data and a link.
NULL The marker for the end of a list.
Polynomial node A node holding a coefficient and an exponent.
Traversal Visiting every node once.
Underflow Deleting from an empty structure.

Question bank

Short Answer Questions (2 marks each)

  1. Define a linked list.
  2. Compare arrays and linked lists.
  3. What is a doubly linked list?
  4. What is a circular linked list?
  5. How is a node inserted at the beginning of a list?
  6. How is a polynomial represented by a linked list?
  7. Define hashing.
  8. What is the division method of hashing?
  9. What is a collision?
  10. Distinguish open addressing and chaining.

Medium Answer Questions (5 marks each)

  1. Explain the representation of a linked list in memory.
  2. Write an algorithm to insert a node at a given position in a singly linked list.
  3. Write an algorithm to delete a node with a given value.
  4. Explain insertion and deletion in a doubly linked list.
  5. Write an algorithm to add two polynomials using linked lists.
  6. Explain the types of hash functions.

Long Answer Questions (15 marks each)

  1. Explain linked lists, their types and their comparison with arrays, with diagrams.
  2. Explain traversal, insertion, deletion and searching in a singly linked list.
  3. Explain doubly and circular linked lists, and the addition of polynomials.
  4. Explain hashing, hash functions, collisions and their resolution by open addressing and chaining.

Sources

  • Official BCA syllabus Data Structures, course code 25BCA402DS02, Unit II