DATA STRUCTURES AND ALGORITHM PRE-MID EXAM STATIC LINEAR DYNAMIC LINEAR
STRUCTURE STRUCTURE
DSA (Data Structures and Algorithm) is defined as a Something that is Something that is
combination of two separate yet interrelated topics. It is specified early or hard intended to be updated
one of the most important skills that every CS/IT coded into a program on the fly.
student must-have. and is not easily changed. Example: Link List, Stack,
Example: Array Queue
What is a Data Structure?
A data structure is defined as a particular way of storing
and organizing data in our devices to use the data
LINEAR
efficiently and effectively.
ARRAY
The main idea behind using data structures is to
minimize the time and space complexities.
An efficient data structure takes minimum memory
space and requires minimum time to execute the data.
What is an Algorithm?
Algorithm is defined as a process or set of well-defined
instructions that are typically used to solve a particular LINKED LIST
group of problems or perform a specific type of
calculation.
It is a set of operations performed in a step-by-step
manner to execute a task.
STACK
LINEAR DATA NON-LINEAR DATA
STRUCTURE STRUCTURE
Elements are accessed in Elements are stored in
a sequential order but non- sequential order.
may be stored
QUEUE
unsystematically.
Data elements are Data elements are
arranged in a linear order attached in hierarchically
manner
Memory is not utilized in Memory is utilized in an
an efficient way efficient way
Mainly in application Artificial Intelligence and
software development image processing
NON-LINEAR //Note: Only Declaration of an array and doesn’t
allocate memory to the array. For that array must be
TREE
initialized.
Values:
int[] x; // can store int values
string[] stud1; // can store string values
double[] d; // can store double values
char [] cHar;// can store char values
GRAPH ADDING A SIZE IN ARRAY
type [ ] < Name_Array > = new < datatype > [size];
Example:
// defining array with size 5.
// But not assigning values
int[] intArray1 = new int[5];
WHY ARRAY DATA STRUCTURES IS NEEDED?
WHAT IS AN ARRAY?
An array is a collection of homogeneous data types
where the elements are allocated contiguous memory.
BASIC TERMINOLOGIES OF ARRAY
Array Index: In an array, elements are identified
by their indexes. Array index starts from 0.
Array element: Elements are items stored in an
array and can be accessed by their index
Array Length: The length of an array is TYPES OF ARRAYS
determined by the number of elements it can
contain. 1. One Dimensional (1D) Array
It is a list of the variable of similar data types.
It allows random access and all the elements
can be accessed with the help of their index.
The size of the array is fixed.
Representation of 1D array.
ARRAY SYNTAX IN C#
Array Declaration:
< Data Type > [ ] < Name_Array >
• It is used for different sorting algorithms such as
2. Two Dimension (2D) Array bubble sort insertion sort, merge sort, and quick
It is a list of lists of the variable of the sort.
same data type.
It also allows random access and all the
elements can be accessed with the help
of their index.
It can also be seen as a collection of 1D
arrays. It is also known as the Matrix.
Its dimension can be increased from 2
to 3 and 4 so on and they all are
referred to as a multi-dimension array.
The most common multidimensional
array is a 2D array.
3. Multidimensional Array
TYPES OF ARRAY OPERATIONS
1. Traversal: Traverse through the elements of an
array.
2. Insertion: Inserting a new element in an array.
3. Deletion: Deleting element from the array.
4. Searching: Search for an element in the array.
5. Sorting: Maintaining the order of elements in
the array.
APPLICATIONS OF ARRAY
• They are used in the implementation of other
data structures such as array lists, heaps, hash
tables, vectors, and matrices.
• Database records are usually implemented as
arrays.
• It is used in lookup tables by computer.