0% found this document useful (0 votes)
58 views3 pages

Quiz 2

The document outlines several lectures covering topics in data structures and algorithms including: dynamic memory allocation using the stack and heap; 2D raster images modelled as arrays; structs and linked lists as data structures; operations on arrays and linked lists including insertion, removal, searching; complexity analysis of algorithms including linear search and binary search; and simple sorting algorithms like selection sort, insertion sort, and bubble sort. File I/O is also introduced including reading and writing arrays and structs to files.

Uploaded by

S CHOWDHURY
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)
58 views3 pages

Quiz 2

The document outlines several lectures covering topics in data structures and algorithms including: dynamic memory allocation using the stack and heap; 2D raster images modelled as arrays; structs and linked lists as data structures; operations on arrays and linked lists including insertion, removal, searching; complexity analysis of algorithms including linear search and binary search; and simple sorting algorithms like selection sort, insertion sort, and bubble sort. File I/O is also introduced including reading and writing arrays and structs to files.

Uploaded by

S CHOWDHURY
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/ 3

Lecture 14 - Stack and Heap - Dynamic Memory Allocation

• Arrays and memory


• Stack: automatic allocation
• Heap: dynamic allocation
• C functions to manage dynamic memory allocation on heap: malloc(…) and free(…)
• Heap vs Stack? Which one to use?
• How large is too large for the Stack?
• Homework: What is happening in this program!

Lecture 15 - Solving our Homework - Raster Image - Arguments to main()

Lecture 16 – 2D Raster Image modelled as Array – Demo

Lecture 17 - struct, typedef, and Data Structures: arrays and linked lists

• Closer look at arrays as a way of creating data structures


• Introduce another way of creating data structures: linked lists
• Struct in C
• Struct along with typedef in C
• Example of new data type: image_t
• Array of struct’s
• Introduce two Data Structures: Array & Linked list
• Array – advantages & disadvantage
• Array Operations or Interface
➢ Insert an element
➢ Remove an element
• Linked list
• Linked list Operations
➢ Insert an element: Prepend (or insert at the front) & Append (or insert at the back)
➢ Remove an element
➢ Search for a particular element
➢ Print its element
Lecture 18 - Data Structures: linked list

• Insert an element into a linked list: Prepand & Append


• Traverse a linked list
• Traverse - do we need the anchor
• Remove an element from a linked list
• Improving time efficiency: O(n) -> O(1) of insertion of an element @ end
• doubly headed singly linked list
• SHSL list: singly headed singly linked list
• DHSL list: doubly headed singly linked list

Lecture 19 - Searching and Complexity Analysis

• Searching - An introduction
• Linear search algorithm & Complexity Analysis
• Various case scenarios
• How to express amount of time? => Time efficiency
• Space Efficiency?
• Big O notation
• Back to Complexity Analysis of linear search algorithm
• Remember Generalisation principle

Lecture 20 - Searching and Complexity Analysis

• Time efficiency analysis of reverse.c


• Big O calculations
• Space efficiency analysis of reverse.c
• Binary Search algorithm
• Time efficiency of Binary Search algorithm
• Space efficiency of Binary Search algorithm
• Binary Search vs Linear Search
Lecture 21 – Simple Sorting Algorithms

• Sorting
• Selection sort
• Time efficiency analysis of selection sort
• Insertion sort
• Time efficiency analysis of insertion sort
• Conclusion – Simple sorting algorithms
• Bubble Sorting
• Time efficiency analysis of bubble sort

Lecture 22 – Simple Sorting Algorithms

• Stability
• Time efficiency analysis of insertion sort

Lecture 23 - Demo: File I/O

• Introducing File I/O


• fopen() and fclose()
• fread() and fwrite()
• Write a simple array to a file
• Read a simple array from a file
• Write an array of structs to a file, then read it back
• Saving and loading an image structure, with error checking
• Shallow-copying entire structs by assignment
• Pointer aliasing
• Deep copy

You might also like