- Discuss the concept of recursion in programming. How does it work, and in what scenarios might recursion be more advantageous than iterative solutions?
- Explain the difference between time complexity and space complexity in algorithms. Why is it important to consider both when evaluating the efficiency of an algorithm?
- What distinguishes linear data structures from non-linear data structures? Provide examples and use cases where one might be preferred over the other.
- Discuss difference between linear and binary search
- In your own words explain the following data structures:
- Linked List
- Stack
- Queues
Lentsoana Hophney
Pamela Gwala
Nokulunga Msabala
importance as to why consider both:
-Considering both time complexity and space complexity when analyzing the efficiency of an algorithm provides a comprehensive understanding of its performance characteristics
Examples:
Array: Stores elements of the same type with indices (e.g., storing prices of cars).
Stack: Follows the LIFO (Last In, First Out) rule (e.g., managing function calls or undo operations).
Non-linear data structures arrange data elements hierarchically, where elements are not connected sequentially.
Examples:
Trees: Hierarchical structure with a root node and child nodes (e.g., file systems, organization charts).
Graphs: Consist of nodes (vertices) connected by edges (e.g., social networks, transportation networks).
4.Linear Search sequentially checks each element in the list until it finds a match or exhausts the list
Binary Search continuously divides the sorted list, comparing the middle element with the target value
5.
A linked list is a data structure consisting of a sequence of elements, called nodes, where each node contains a reference (or link) to the next node in the sequence.
A stack is a fundamental data structure in computer science that follows the Last In, First Out (LIFO) principle.
A queue is another fundamental data structure in computer science, following the First In, First Out (FIFO) principle.
stack