0% found this document useful (0 votes)
17 views

Chapter 7 (Data Structures)

Uploaded by

sharad9shashwat
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Chapter 7 (Data Structures)

Uploaded by

sharad9shashwat
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

GD GOENKA INTERNATIONAL SCHOOL

NOIDA EXTENSION
CLASS 12
COMPUTER SCIENCE
CHAPTER 7. DATA STRUCUTRES
• Elementary representation of data can be in forms of raw data, data
item, data structures.
• Raw Data are raw facts. These are simply values or set of values.
• Data item represents single unit of values of certain type.
• A data structure is a named group of data of different data types which
is stored in a specific way and can be processed as a single unit. A data
structure has well- defined operations, behavior and properties.
Data Type vs Data Structures: A data type defines a set of values along with
well- defined operations stating its input- output behavior. On the other hand,
a Data structure is a physical implementation that clearly defines a way of
storing, accessing, manipulating data stored in a data structure.
Different Data Structures: There are two types of data structures:
• Simple Data Structures: These data structures are normally built from
primitive data types like integers, reals, characters, Boolean. Array or
Linear Lists are simple data structures.
• Compound Data Structures: Simple data structures can be combined in
various ways to form more complex structures called compound data
structures. Compound data structures are classified into two types:
o Linear data structures: These data structures are single level data
structures. A data structure is said to be linear if its elements form
a sequence. Examples: Stack Queue Linked List
Python’s built- in linear data structures are: lists, tuples,
dictionaries, sets
o Non- Linear data structures: These are multilevel data structures.
Examples: Tree
Linear Lists Arrays: Linear lists or arrays refer to a named list of a finite number
of similar data elements. Arrays can be one dimensional, two dimensional or
multi-dimensional. In Python, arrays are implemented through List data types
as Linear Lists or through NumPy arrays.
Stacks: Stacks data structures refer to the lists stored and accessed in a special
way, where LIFO (Last in First Out) technique is followed. In stacks, insertions
and deletions take place only at one end, called the top.
Queues: Queues data structures are FIFO (First in First Out) lists, where
insertions take place at the ‘rear’ end of the queues and deletions take place at
the ‘front’ end of the queues.
Linked Lists: Linked lists are special lists of some data elements linked to one
another. The logical ordering is represented by having each element pointing to
the next element. Each element is called a node, which has two parts. The INFO
part which stores the information and the reference- pointer part, which points
to stores the reference of the next element. There are two types of Linked Lists:
• In Single Linked Lists, nodes have one reference- pointer (next) pointing
to the next node.
• In Doubly Linked Lists, nodes have two reference- pointers (prev and
next). Prev points to the previous node and next points to the next node
in the list.
Trees: Trees are multilevel data structures having a hierarchical relationship
among its elements called nodes. Topmost node is called the root of the tree
and the bottommost nodes are called leaves of the tree.
Operations of Data Structures:
• Insertion: Addition of a new data element in a data structure.
• Deletion: Removal of a data element from a data structure. The data
element is searched for before its removal.
• Searching: Involves searching for the specified data element in a data
structure.
• Traversal: Processing all the data elements of it, one by one.
• Sorting: Arranging data elements of a data structure in a specified order
is called sorting.
• Merging: Combining elements of two similar data structures to form a
new data structure of same type.
Stacks: Stack follow the following rules:
• Data can be removed from the top (pop) i. e., the element at the top of
the stack. The removal of element from a stack is technically called POP
Operation.
• A new data element can only be added to the top of the stack (push).
The insertion of element in a stack is technically called PUSH Operation.
A stack is a dynamic data structure as it can grow (with increase in number of
elements) or shrink (with decrease in number of elements). A static data
structure on the other hand, is the one that has fixed size.
Other Stack Terms:
• Peek: Refers to inspecting the value at the stack’s top without removing
it. It is also sometimes referred as inspection.
• Overflow: Refers to the situation (ERROR) when one tries to push an
item in stack that is full. This situation occurs when the size of the stack
and cannot grow further or there is no memory left to accommodate
new item.
• Underflow: Refers to the situation (ERROR) when one tries to pop/
delete an item from an empty stack. That is, stack is currently having no
item and still one tries to pop an item.
Refer example 7.1 on page 281 for understanding the concept of POP, PUSH,
UNDERFLOW and OVERFLOW in stack.
Stack Application:
• Reversing a Line: We can accomplish this task by pushing each character
on to a stack as it is read. When the line is finished, characters are then
popped off the stack, and they will come off in the reverse order.
Refer heading 7.5.2A for understanding this concept through example.
• Polish Strings: Conversion of arithmetic expressions in high- level
programming languages into machine readable form. As our computer
system only understands and work on a binary language, it assumes that
an arithmetic operation can take place in two operands only. But in our
usual form an arithmetic expression may consist of more than one
operator and two operands. These complex arithmetic operations can be
converted into polish strings using stacks which then can be executed in
two operands and an operator form.
Polish string named after a polish mathematician, Jan Lukasiewiez,
refers to the notation in which the operator symbol is placed either
before its operands (prefix notation) or after its operands (postfix
notation) in contrast to usual form where operator is placed in between
the operands (infix notation).

• For Understanding Implementing Stacks In Python, click the given link:


https://youtu.be/woNTCp2Dzzc?si=AEvl7XbxrKe1cPN6
• For Understanding the concept of PUSH, POP, UNDERFLOW and
OVERFLOW, click the given link:
https://youtu.be/NArCnniROi0?si=Ji9ohgrmzyAKh5hu
• For Understanding the conversion of infix to postfix expressions, click
the given link: https://youtu.be/vCpkyye4i3c?si=lduBdW9cpyG_XDjR

You might also like