0% found this document useful (0 votes)
13 views19 pages

Week 1 DS

Uploaded by

Hadia Butt
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)
13 views19 pages

Week 1 DS

Uploaded by

Hadia Butt
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/ 19

Well Come to

Data Structure from Scratch


Theory + Practical
What is Data Structure
& Algorithm and Pseudocode

Purpose of this course


Learn Data Structure
(Both way) Learn to Pass
and Pass to get Job!
What is Data Structure
& Algorithm and Pseudocode
A data structure is a particular way of organizing data in a computer so that it can be used
effectively. For example, we can store a list of items having the same data-type using the
array data structure.

The Algorithm is a finite sequence of well-defined, computer-implementable instructions,


typically to solve a class of problems or to perform a computation. Algorithms are
unambiguous specifications for performing calculation, data processing, automated
reasoning, and other tasks.

Pseudocode (Fake Code) is an informal high-level description of the operating principle of a


computer program or other algorithm
Algorithm and Pseudocode

#include <stdio.h>
int main()
{
int firstNumber, secondNumber,
sumOfTwoNumbers;
printf("Enter two integers: ");
scanf("%d %d", &firstNumber, &secondNumber);
sumOfTwoNumbers = firstNumber +
secondNumber;

printf("%d + %d = %d", firstNumber,


secondNumber, sumOfTwoNumbers);
return 0;
Algorithm Pseudo Code } Program(C lang)
Data Structure Types
Data Structure Types
Primitive DS and non primitive DS

Linear DS and Non Linear DS

Static and Dynamic DS

Homogenous and Non


Homogenous
Thank You!
Data Structure Types
Data types | Abstract Data type

List
Stack
Queue
Example of Abstract Data Type

Abstract Data type (ADT) is


a type (or class) for objects
whose behavior is defined by a
set of value and a set of
operations. ... Think of ADT as a
black box which hides the
inner structure and design of
the data type.
Thank You!
Data Structure Types
Array Data Structure
Linear Data Structure which is a collection of data items having similar data types
(homogenous) stored in contiguous memory location. By knowing the address of the
first item we can easily access all items/elements of an array.
Array Data Structure (Length)

Length = upper_bound – lower_bound + 1


Array calculate the address
Array Data Structure
Array Data Structure

There are a number of operations that can be preformed on


arrays.

• Traversing an array
• Inserting an element in an array
• Searching an element in an array
• Deleting an element from an array
• Merging two arrays
• Sorting an array in ascending or descending
order
Array (address) and (Pointer)

Pointer is the reference of the value of other variable.


Array Usage
• Arrays are widely used to implement mathematical vectors, matrices,
and other kinds of rectangular tables.

• Many databases include one-dimensional arrays whose elements are


records.

• Arrays are also used to implement other data structures such as


strings, stacks, queues, heaps, and hash tables. We will read about
these data structures in the subsequent chapters.

• Arrays can be used for sorting elements in ascending or descending


order
Array
Advantages
Multiple data items of same data type can be accessed using single name
Arrays can be used to implement matrices
Data structure like queue , linked list can be accessed using arrays

Disadvantages
We must know in advance that how many elements are to be stored in an array
Array is static structure. It means that array is of fixed size. The memory which is
allocated to array can not be increased or reduced.
Insertion and deletion are quite difficult in array. As the elements are stored in
consecutive memory locations.

You might also like