0% found this document useful (0 votes)
2 views

Basics of Data Structures (1)

The document outlines a curriculum on C programming, focusing on data structures such as linked lists, binary search trees, and lookup tables. It includes a quiz section with questions related to file handling and program execution, as well as common operations for each data structure. Additionally, it provides a homework assignment to create a C program for managing student details with various functionalities.

Uploaded by

maariaam.gh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Basics of Data Structures (1)

The document outlines a curriculum on C programming, focusing on data structures such as linked lists, binary search trees, and lookup tables. It includes a quiz section with questions related to file handling and program execution, as well as common operations for each data structure. Additionally, it provides a homework assignment to create a C program for managing student details with various functionalities.

Uploaded by

maariaam.gh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

The C Programming Language

Basics of Data Structures


Agenda


Quiz

Linked List

Binary Search Tree

Lookup Table

Homework
Quiz


What are the standard library functions for reading and writing
from files ? What should be done before and after using these
functions ?

What are the files that operating system automatically opens
when the program is executed ?

How can we terminate the program ?

How can we pass output of one program as an input to
another ?

Is it possible to pass variable length argument lists to
functions ? If yes, then explain how ?
Linked List

A linked list is a linear data structure that includes a series of
connected nodes.

Typically a node contains a data and a pointer to the address of the
next node in the memory.

The first node is called HEAD.

The last node of the list contains pointer to the null.

Linked lists nodes are not stored at a contiguous location, rather they
are linked using pointers to the different memory locations.
Linked List

Common operations on linked lists:
– Insertion (at begining, at end, after node)
– Deletion (at begining, at end, at node)
– Search (by key)
– Traversal

Efficient insertions/deletions (O(1) for head operations)

Sequential access (O(n) for searching).
Linked List
Linked List
Linked List
Linked List
Linked List
Linked List
Linked List
Linked List
Binary Search Tree

A binary tree is a hierarchical data structure in which each node has
at most two children, referred to as the left child and the right child.

A Binary Search Tree is a binary tree where:
– Each node contains a key.
– The key in the left subtree of a node is smaller than the key in the
node.
– The key in the right subtree of a node is greater than the key in
the node.
– Left and right subtrees are also BSTs.

The in-order traversal of a BST gives keys in sorted order.

Average time complexity for basic operations (search, insert, delete)
is O(log⁡n), but in the worst case (skewed tree), it is O(n).
Binary Search Tree

Common Operations on BST
– Insertion
– Deletion
– Search
– Traversal (In-order, Pre-order, Post-order)
Binary Search Tree
Binary Search Tree
Binary Search Tree
Binary Search Tree
Binary Search Tree
Lookup Table

A Lookup Table (Hash Table) is a data structure that stores
precomputed results for efficient retrieval.

It operates on the hashing concept, where each key is translated by a
hash function into a distinct index in an array.

The advantage of hash tables is the fast lookup – O(1) in practice.

This data structure is used in:
– Spell checking tools
– Network routing tables
– Cache sytstems
Lookup Table

The common operations of the lookup tables are:
– Initialization
– Insertion
– Lookup
– Deletion
Lookup Table
Lookup Table
Lookup Table
Lookup Table
Homework
Write a C program to store and manage student details (name,
surname, ID, and grade). Include the following operations in the menu
driven user interface:
– Add a new student to the list.
– Remove a student by ID.
– Search a student by ID.
– Display all student details.
– Display average grade of all students.
– Save student details into “group_details.csv” file – every student
detail in a new line and the details separated by commas.
– Read student details from a file.
Ensure that memory is dynamically allocated and properly freed when
students are removed or the program ends.
Thank You !

You might also like