
















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The fundamentals of data structures and algorithms, which are essential topics in computer science and engineering. It introduces common data structures such as arrays, lists, stacks, queues, graphs, and trees, and discusses how to analyze their efficiency in terms of space and time complexity. The document also provides examples of algorithms in programming, including adding two numbers and finding the largest among three numbers. It explains the concept of abstract data types and the differences between scalar, linear, and nonlinear data structures. Additionally, the document covers pointers, their usage, and how they can be used as function parameters. This comprehensive overview of data structures and algorithms would be valuable for university students studying computer science, computer engineering, or related fields, as it provides a solid foundation for understanding and applying these fundamental concepts in problem-solving and software development.
Typology: Essays (high school)
1 / 24
This page cannot be seen from the preview
Don't miss anything!

















Instr. Sarra Elrabiei Fall 2023/
University of Tripoli
Faculty of Engineering- Computer Engineering Depa ment
Data structure: A container class that provides storage for data items and capabilities for storing and retrieving data items.
Common data structures—Arrays, lists, stacks, queues, graphs, and trees.
Set Stack^ Tree
Arrays, Stacks, Tables, Trees …etc (Data Structures) So ing data ( Varies algorithms such as Selection, Bubble & Merge) Routing communication algorithms (Find sho est path) Database indices rely on search Tree & Tables data structures Search engines Such as Google use algorithms; such as PageRank algorithm , to rank impo ance of websites Graphics needs geometric algorithms to compute primitives shapes
Algorithms Analysis: Space: amount of memo required to complete an algorithm Time: Algorithm running time
Algorithms can be expressed in many kinds of notation such as pseudocode and owcha s.
An algorithm to nd the largest among three di erent numbers entered by user.
Step 1: Sta Step 2: Declare variables a,b and c. Step 3: Read variables a,b and c. Step 4: If a>b If a>c Display a is the largest number. Else Display c is the largest number. Else If b>c Display b is the largest number. Else Display c is the greatest number. Step 5: Stop
Example (2):
What are some of the common data structures?
What are some ways to implement them?
How to analyze their e ciency?
How to use them to solve practical problems?
Sol. 1 Sequential matching: 1 sec. x 600,000 words = 166 hours Sol. 2 Bina searching:
Ex. Search 25 in 5 8 12 15 15 17 23 25 27 25? 15 15 17 23 25 27 25? 23 23 25 27 25? 25 How many steps?
A data type can be considered abstract when it is de f in e d by a s e t o f v a lu e a n d a s e t o f operations.
An Abstract Data Type (ADT) is: a set of values a set of operations, which can be applied uniformly to all these values The def inition of ADT only mentions what operations are to be per formed but not how these operations will be implemented. It does not specify how data will be organized in memo a n d w h a t a l g o r i t h m s w i l l b e u s e d f o r implementing the operations.
Linear data structure : A container that holds one or more values at a time Elements are adjacent to each other (2 neighbours). Examples,
Nonlinear data structure : A container that holds one or more values at a time. One element can be connected to more than two adjacent element.
13
– – A Pointer is an address Pointers simplify the transfer of information from one location to another. When two functions operate on the same set of data, passing along the address is more ef ficient than a copy of the data itself. That is improve speed Save space Also pointers allow the function to change more than one variable.
When a variable is def ined the compiler (linker/loader actually) allocates a real memo address for the variable. int x;
It will allocate 4 bytes in the main memor y, which will be used to store an integer value.
When a value is assigned to a variable, the value is actually placed to the memo that was allocated. x=3; It will store integer 3 in the 4 bytes of memo .
00000000 00000000 00000000 00000011
x
To declare a pointer variable
type * pointername;
Example:
int *p;
Memo
(^) The variable p is pointer to an integer.
int *a;
int b = 17;
a=&b;
int main() { int n=44; cout << "n = " << n << ", &n = " << &n << endl; int* pn=&n; // pn holds the address of n cout << " pn = " << pn << endl; cout << "&pn = " << &pn << endl; }
This program de nes the int variable n and the int*
variable pn: