This document provides an introduction to data structures and algorithms. It defines data structures as a way of organizing data that considers both the items stored and their relationship. Common data structures include stacks, queues, lists, trees, graphs, and tables. Data structures are classified as primitive or non-primitive based on how close the data items are to machine-level instructions. Linear data structures like arrays and linked lists store data in a sequence, while non-linear structures like trees and graphs do not rely on sequence. The document outlines several common data structures and their characteristics, as well as abstract data types, algorithms, and linear data structures like arrays. It provides examples of one-dimensional and two-dimensional arrays and how they are represented in
The document is a comprehensive guide on data structures using C, covering various topics such as arrays, stacks, queues, linked lists, trees, graphs, and sorting/searching algorithms. It includes operations like insertion, deletion, searching, and updating elements in arrays, along with explanations of sparse matrix representations and implementations. Additionally, it provides references to textbooks and a structured overview of each topic within data structures.
DS Complete notes for Computer science and EngineeringRAJASEKHARV8
The document provides information about data structures using C programming language. It discusses various topics like arrays, linked lists, stacks, queues, trees and graphs. It provides the syllabus, contents and references for the course on data structures. The document contains lecture notes on different data structure topics with examples and algorithms for common operations like search, insertion, deletion on arrays and linked lists.
The document discusses data structures and algorithms. It defines data structures as a way of organizing data that considers both the items stored and their relationship. Common data structures include stacks, queues, lists, trees, and graphs. Linear data structures store data in a sequence, while non-linear data structures have no inherent sequence. The document also defines algorithms as finite sets of instructions to accomplish tasks and discusses properties like input, output, definiteness, and termination. Common algorithms manipulate linear data structures like arrays and linked lists.
Data Structures and algoithms Unit - 1.pptxmexiuro901
The document provides a comprehensive overview of data structures, explaining the definitions and classifications into primitive and non-primitive structures, such as linear and non-linear types. It outlines key operations performed on data structures, including traversing, insertion, deletion, searching, and sorting, along with specific algorithms related to these operations. Additionally, it discusses characteristics of data structures, abstract data types, and various searching and sorting techniques, highlighting their complexities and advantages.
Chapter 4 discusses data structures, focusing on the organization and operation of data. It differentiates between primitive and non-primitive data structures, outlining key operations such as creation, traversal, insertion, deletion, searching and sorting. Additionally, it covers arrays, including their types, basic operations, and specific algorithms for searching elements like linear and binary search.
The document provides information on data structures. It defines data structures as how data is organized and stored to allow for efficient operations. Primitive data structures include basic data types like integers while non-primitive structures are derived from primitives, including arrays, lists, stacks, queues, linked lists, trees and graphs. Linear structures like stacks and queues have elements in sequence while non-linear structures like trees and graphs have hierarchical relationships. Common operations on data structures are traversing, inserting, deleting, searching and sorting. Arrays are introduced as ordered collections of homogeneous elements accessed via indices. One-dimensional arrays are described along with operations like traversal, insertion, deletion and linear/binary search.
This document provides an introduction to data structures presented by Prof. K. Adisesha. It defines data structures as representations of logical relationships between data elements that consider both the elements and their relationships. Data structures affect both structural and functional aspects of programs. They are classified as primitive or non-primitive, with primitive structures operated on directly by machine instructions and non-primitive structures derived from primitive ones. Linear data structures like stacks and queues have elements in sequence, while non-linear structures like trees and graphs have hierarchical or parent-child relationships. Common operations on data structures include traversal, insertion, selection, searching, sorting, merging, and deletion. Arrays are also discussed in detail as a fundamental data structure.
This document describes a course on data structures taught by Dr. Raidah Salim. The course objectives are to teach students about various data structures including arrays, strings, linked lists, stacks, and queues. It then provides an introduction to data structures, describing them as a way to organize and store data for efficient access and modification. The document goes on to classify different types of data structures and describe various operations that can be performed on data structures like traversing, searching, inserting, deleting, and sorting. It also discusses arrays and linked lists in more detail.
Here is the output of the given code segment:
int count = 0;
double sum = 0;
for (int row = 0; row <jagged.length; row++) {
count += jagged[row].length;
for(int col=0; col<jagged[row].length; col++) {
sum += jagged[row][col];
}
}
System.out.println("Number of elements: " + count);
System.out.println("Sum of all elements: " + sum);
The output would be:
Number of elements: 15
Sum of all elements: 52.0
The outer for loop iterates
EC2311 – Data Structures and C ProgrammingPadma Priya
The document covers linear data structures and their implementations in C programming, focusing on abstract data types (ADTs) such as lists, stacks, and queues. It discusses the characteristics and operations of each data structure, including traversal, search, insertion, and deletion, and differentiates between static and dynamic structures. Additionally, it provides implementation details, advantages, and disadvantages of using arrays and linked lists for these structures.
Data structures are used to organize data efficiently to perform operations on large amounts of data. They include primitive structures like integers and floats, as well as linear structures like arrays, stacks, and queues and non-linear structures like trees and graphs. Common operations on data structures include traversing, inserting, deleting, searching, and sorting data elements. Understanding which data structure to use for a given problem is important to write efficient programs as data volumes continue growing rapidly.
This document provides an introduction to data structures. It discusses primitive and non-primitive data structures and their classifications. Linear data structures like arrays, stacks, queues and linked lists are covered, along with non-linear structures like trees and graphs. Common operations on data structures like traversing, searching, inserting and deleting are also summarized. Finally, the document introduces abstract data types and provides examples of common ADT specifications for lists, stacks and queues.
The document provides an introduction to data structures. It defines data structures as representations of logical relationships between data elements that consider both the elements and their relationships. It classifies data structures as either primitive or non-primitive. Primitive structures are directly operated on by machine instructions while non-primitive structures are built from primitive ones. Common non-primitive structures include stacks, queues, linked lists, trees and graphs. The document then discusses arrays as a data structure and operations on arrays like traversal, insertion, deletion, searching and sorting.
8.DATA STRUCTURES UNIT 1 AND 2 CS3301PPT.pptxvenigkrish89
The document provides an extensive overview of data structures, specifically focusing on lists and abstract data types (ADTs). It discusses linear and non-linear data structures, their operations such as creation, insertion, deletion, and modification, while explaining the conceptual differences between arrays and linked lists. Additionally, it covers various types of linked lists including singly linear, circular, doubly linear, and doubly circular linked lists, alongside their operations and implementation challenges.
This document discusses various common data structures, including their definitions, examples, and basic operations. It begins by defining an abstract data type and explaining that a data structure provides one way to implement an ADT by organizing data. Then it provides examples of common data structures like queues, stacks, binary search trees, lists, arrays, linked lists, graphs, and hashing. For each it briefly explains what it is, potential applications, and some basic operations that can be performed on it.
This document discusses linear and non-linear data structures. Linear data structures like arrays, stacks, and queues store elements sequentially. Static linear structures like arrays have fixed sizes while dynamic structures like linked lists can grow and shrink. Non-linear structures like trees and graphs store elements in a hierarchical manner. Common abstract data types (ADTs) include stacks, queues, and lists, which define operations without specifying implementation. Lists can be implemented using arrays or linked lists.
This document provides an introduction to data structures. It discusses primitive and non-primitive data structures and their classifications. Linear data structures like arrays, stacks, queues and linked lists are covered, along with non-linear structures like trees and graphs. Common operations on data structures are also summarized such as traversing, searching, inserting and deleting. Finally, abstract data types and examples of common ADTs like lists, stacks and queues are introduced.
The document discusses different data structures and their properties. It explains that data structures can be linear or non-linear. Linear data structures like arrays have elements arranged in a sequence, while non-linear structures like trees and graphs do not. It then focuses on linear data structures and their representation in memory using arrays and linked lists. Key operations on linear structures like traversal, search, insertion and deletion are also summarized.
The document discusses different data structures like arrays, stacks, queues, linked lists, trees, graphs. It provides definitions of each data structure and describes their common operations like traversing, searching, insertion, deletion. It also includes algorithms for operations on linear arrays, stacks, queues and priority queues. Implementation of different data structures and their applications are explained with examples.
Introduction to Data Structures and their importanceBulbul Agrawal
The presentation by Ms. Bulbul Agrawal introduces data structures, emphasizing their importance for organizing and utilizing data in computer science. It covers the classification of data structures into primitive and non-primitive types, fundamental operations, and various examples including arrays, stacks, queues, linked lists, trees, and graphs. The document also outlines course objectives and expected outcomes for students studying the effective use of data structures.
This document discusses data structures and algorithms. It defines data types and data structures, and provides examples of common data structures like arrays, linked lists, stacks, queues, and trees. It also discusses operations on data structures like traversing, searching, inserting, and deleting. Algorithms are used to manipulate the data in data structures. The time and space complexity of algorithms are also introduced. Overall, the document provides an overview of key concepts related to data structures and algorithms.
The document discusses linear data structures using sequential organization. It begins by defining sequential organization as arranging data in a linear order within computer memory such that each element has a unique successor. Arrays are presented as a fundamental example of a sequentially organized data structure, where elements are stored in consecutive memory locations and can be accessed randomly in constant time. The document then covers topics like multi-dimensional arrays, ordered lists, and operations on arrays like insertion, deletion, and retrieval. It also discusses representation of arrays and calculating element addresses.
A data structure is a way of storing data in computer memory so that it can be retrieved and manipulated efficiently. There are two main categories of data structures: linear and non-linear. Linear data structures include arrays, stacks, and queues where elements are stored in a linear order. Non-linear structures include trees and graphs where elements are not necessarily in a linear order. Common operations on data structures include traversing, searching, insertion, deletion, sorting, and merging. Algorithms use data structures to process and solve problems in an efficient manner.
This document discusses data structures and provides examples of different linear data structures including arrays, stacks, queues, and linked lists. It begins by defining what a data structure is, explaining that a data structure organizes data in a systematic way to allow for efficient use. The document then reviews key concepts about each linear data structure, including common operations, implementations using arrays vs pointers, and examples of applications that each data structure can be used for. Real-world examples are provided to illustrate common uses of different data structures.
data structure unit -1_170434dd7400.pptxcoc7987515756
The document discusses data structures and their importance in organizing large amounts of data efficiently. It describes primitive data structures like integers and characters that are supported at a low level. Non-primitive structures like arrays, files, stacks, queues, graphs and trees are built using primitive structures. Arrays store homogeneous data in contiguous memory locations and support random access. Stacks follow LIFO while queues follow FIFO for element insertion and removal. Formulas to calculate memory addresses of array elements are also provided.
This document describes a course on data structures taught by Dr. Raidah Salim. The course objectives are to teach students about various data structures including arrays, strings, linked lists, stacks, and queues. It then provides an introduction to data structures, describing them as a way to organize and store data for efficient access and modification. The document goes on to classify different types of data structures and describe various operations that can be performed on data structures like traversing, searching, inserting, deleting, and sorting. It also discusses arrays and linked lists in more detail.
Here is the output of the given code segment:
int count = 0;
double sum = 0;
for (int row = 0; row <jagged.length; row++) {
count += jagged[row].length;
for(int col=0; col<jagged[row].length; col++) {
sum += jagged[row][col];
}
}
System.out.println("Number of elements: " + count);
System.out.println("Sum of all elements: " + sum);
The output would be:
Number of elements: 15
Sum of all elements: 52.0
The outer for loop iterates
EC2311 – Data Structures and C ProgrammingPadma Priya
The document covers linear data structures and their implementations in C programming, focusing on abstract data types (ADTs) such as lists, stacks, and queues. It discusses the characteristics and operations of each data structure, including traversal, search, insertion, and deletion, and differentiates between static and dynamic structures. Additionally, it provides implementation details, advantages, and disadvantages of using arrays and linked lists for these structures.
Data structures are used to organize data efficiently to perform operations on large amounts of data. They include primitive structures like integers and floats, as well as linear structures like arrays, stacks, and queues and non-linear structures like trees and graphs. Common operations on data structures include traversing, inserting, deleting, searching, and sorting data elements. Understanding which data structure to use for a given problem is important to write efficient programs as data volumes continue growing rapidly.
This document provides an introduction to data structures. It discusses primitive and non-primitive data structures and their classifications. Linear data structures like arrays, stacks, queues and linked lists are covered, along with non-linear structures like trees and graphs. Common operations on data structures like traversing, searching, inserting and deleting are also summarized. Finally, the document introduces abstract data types and provides examples of common ADT specifications for lists, stacks and queues.
The document provides an introduction to data structures. It defines data structures as representations of logical relationships between data elements that consider both the elements and their relationships. It classifies data structures as either primitive or non-primitive. Primitive structures are directly operated on by machine instructions while non-primitive structures are built from primitive ones. Common non-primitive structures include stacks, queues, linked lists, trees and graphs. The document then discusses arrays as a data structure and operations on arrays like traversal, insertion, deletion, searching and sorting.
8.DATA STRUCTURES UNIT 1 AND 2 CS3301PPT.pptxvenigkrish89
The document provides an extensive overview of data structures, specifically focusing on lists and abstract data types (ADTs). It discusses linear and non-linear data structures, their operations such as creation, insertion, deletion, and modification, while explaining the conceptual differences between arrays and linked lists. Additionally, it covers various types of linked lists including singly linear, circular, doubly linear, and doubly circular linked lists, alongside their operations and implementation challenges.
This document discusses various common data structures, including their definitions, examples, and basic operations. It begins by defining an abstract data type and explaining that a data structure provides one way to implement an ADT by organizing data. Then it provides examples of common data structures like queues, stacks, binary search trees, lists, arrays, linked lists, graphs, and hashing. For each it briefly explains what it is, potential applications, and some basic operations that can be performed on it.
This document discusses linear and non-linear data structures. Linear data structures like arrays, stacks, and queues store elements sequentially. Static linear structures like arrays have fixed sizes while dynamic structures like linked lists can grow and shrink. Non-linear structures like trees and graphs store elements in a hierarchical manner. Common abstract data types (ADTs) include stacks, queues, and lists, which define operations without specifying implementation. Lists can be implemented using arrays or linked lists.
This document provides an introduction to data structures. It discusses primitive and non-primitive data structures and their classifications. Linear data structures like arrays, stacks, queues and linked lists are covered, along with non-linear structures like trees and graphs. Common operations on data structures are also summarized such as traversing, searching, inserting and deleting. Finally, abstract data types and examples of common ADTs like lists, stacks and queues are introduced.
The document discusses different data structures and their properties. It explains that data structures can be linear or non-linear. Linear data structures like arrays have elements arranged in a sequence, while non-linear structures like trees and graphs do not. It then focuses on linear data structures and their representation in memory using arrays and linked lists. Key operations on linear structures like traversal, search, insertion and deletion are also summarized.
The document discusses different data structures like arrays, stacks, queues, linked lists, trees, graphs. It provides definitions of each data structure and describes their common operations like traversing, searching, insertion, deletion. It also includes algorithms for operations on linear arrays, stacks, queues and priority queues. Implementation of different data structures and their applications are explained with examples.
Introduction to Data Structures and their importanceBulbul Agrawal
The presentation by Ms. Bulbul Agrawal introduces data structures, emphasizing their importance for organizing and utilizing data in computer science. It covers the classification of data structures into primitive and non-primitive types, fundamental operations, and various examples including arrays, stacks, queues, linked lists, trees, and graphs. The document also outlines course objectives and expected outcomes for students studying the effective use of data structures.
This document discusses data structures and algorithms. It defines data types and data structures, and provides examples of common data structures like arrays, linked lists, stacks, queues, and trees. It also discusses operations on data structures like traversing, searching, inserting, and deleting. Algorithms are used to manipulate the data in data structures. The time and space complexity of algorithms are also introduced. Overall, the document provides an overview of key concepts related to data structures and algorithms.
The document discusses linear data structures using sequential organization. It begins by defining sequential organization as arranging data in a linear order within computer memory such that each element has a unique successor. Arrays are presented as a fundamental example of a sequentially organized data structure, where elements are stored in consecutive memory locations and can be accessed randomly in constant time. The document then covers topics like multi-dimensional arrays, ordered lists, and operations on arrays like insertion, deletion, and retrieval. It also discusses representation of arrays and calculating element addresses.
A data structure is a way of storing data in computer memory so that it can be retrieved and manipulated efficiently. There are two main categories of data structures: linear and non-linear. Linear data structures include arrays, stacks, and queues where elements are stored in a linear order. Non-linear structures include trees and graphs where elements are not necessarily in a linear order. Common operations on data structures include traversing, searching, insertion, deletion, sorting, and merging. Algorithms use data structures to process and solve problems in an efficient manner.
This document discusses data structures and provides examples of different linear data structures including arrays, stacks, queues, and linked lists. It begins by defining what a data structure is, explaining that a data structure organizes data in a systematic way to allow for efficient use. The document then reviews key concepts about each linear data structure, including common operations, implementations using arrays vs pointers, and examples of applications that each data structure can be used for. Real-world examples are provided to illustrate common uses of different data structures.
data structure unit -1_170434dd7400.pptxcoc7987515756
The document discusses data structures and their importance in organizing large amounts of data efficiently. It describes primitive data structures like integers and characters that are supported at a low level. Non-primitive structures like arrays, files, stacks, queues, graphs and trees are built using primitive structures. Arrays store homogeneous data in contiguous memory locations and support random access. Stacks follow LIFO while queues follow FIFO for element insertion and removal. Formulas to calculate memory addresses of array elements are also provided.
NVIDIA Triton Inference Server, a game-changing platform for deploying AI mod...Tamanna36
NVIDIA Triton Inference Server! 🌟
Learn how Triton streamlines AI model deployment with dynamic batching, support for TensorFlow, PyTorch, ONNX, and more, plus GPU-optimized performance. From YOLO11 object detection to NVIDIA Dynamo’s future, it’s your guide to scalable AI inference.
Check out the slides and share your thoughts! 👇
#AI #NVIDIA #TritonInferenceServer #MachineLearning
Starbucks in the Indian market through its joint venture.sales480687
This topic focuses on the growth and challenges of Starbucks in the Indian market through its joint venture with Tata. It covers localization strategies, menu adaptations, expansion goals, and financial performance. The topic also examines consumer perceptions, market competition, and how Starbucks navigates economic and cultural factors in one of its most promising international markets.
based on assumption that failure of such a weld is by shear on the
effective area whether the shear transfer is parallel to or
perpendicular to the axis of the line of fillet weld. In fact, the
strength is greater for shear transfer perpendicular to the weld axis;
however, for simplicity the situations are treated the same.
Data warehouses, lakes, lakehouses, streams, fabrics, hubs, vaults, and meshes. We sometimes choose deliberately, sometimes influenced by trends, yet often get an organic blend. But the choices have orders of magnitude in impact on operations cost and iteration speed. Let's dissect the paradigms and their operational aspects once and for all.
2. A data structure is a special way of organizing
and storing data in a computer so that it can be
used efficiently.
Data structures are the building blocks of any
program or the software.
Data Structures enable the programmers to
handle the data in an efficient way.
3. Basic Terminology
Data: Data can be defined as an elementary value or
the collection of values.
Example - student's name and his id are the data
about the student.
Group Items: Data items which have subordinate
data items are called Group item.
Example -name of a student can have first name and
the last name.
Record: Record can be defined as the collection of
various data items.
Example, if student is an entity, then name, address,
course and marks can be grouped together to form
the record for the student.
4. File: A File is a collection of various records of one
type of entity.
Example: If there are 20 students in a class, then
there will be 20 records, and each record contains
the data about a student.
Attribute and Entity: An entity represents the class
of certain objects and it contains various attributes.
Each attribute represents the particular property of
that entity.
Example : Student is an entity
Deptno, name, sub1 are attributes
Field: Field is a single elementary unit of information
representing the attribute of an entity.
5. Need of Data Structures
Processor speed: If we have a large amount of data, high
speed processing is required. Representing data with a
particular format may remove the unwanted data there
by increase the processing speed.
Data Search: In a large amount of data, if the
representation of data is not proper then finding out a
particular data is a very complex task.
Multiple requests: If thousands of users are searching the
data simultaneously on a web server, if data are not
organized in a format then there are the chances of
failure in server.
6. Advantages of Data Structures
Efficiency: Efficiency of a program depends
upon the choice of data structures.
Reusability: Data structures are reusable, i.e.
once we have implemented a particular data
structure, we can use it at any other place.
Abstraction: Data structure is specified by the
ADT which provides a level of abstraction. The
client program uses the data structure through
interface only, without getting into the
implementation details.
8. Linear Data Structures: A data structure is called
linear if all of its elements are arranged in the linear
order.
In linear data structures, the elements are stored in
non-hierarchical way where each element has the
successors and predecessors except the first and last
element.
.
9. Types of Linear Data Structures
Static:
Arrays: An array is a collection of similar type of data
items and each data item is called an element of the
array.
It is static because its size should be specified before
using it.
The data type of the element may be any valid data
type like char, int, float or double.
10. Types of Linear Data Structures
Static:
Linked List: Linked list is a linear data structure
which is used to maintain a list in the memory.
It can be seen as the collection of nodes stored at
non-contiguous memory locations.
Each node of the list contains a pointer to its
adjacent node.
Stack: Stack is a linear list in which insertion and
deletions are allowed only at one end, called top.
It is named as stack because it behaves like a real-
world stack, for example: deck of cards.
11. Queue: Queue is a linear list in which elements can
be inserted only at one end called rear and deleted
only at the other end called front.
It is an abstract data structure, similar to stack.
Queue is opened at both end therefore it follows
First-In-First-Out (FIFO) methodology for storing
the data items.
12. Non Linear Data Structures
This data structure does not form a sequence i.e.
each item or element is connected with two or
more other items in a non-linear arrangement.
The data elements are not arranged in sequential
structure.
Types of Non Linear Data Structures
Trees
Graphs
13. Trees: Trees are multilevel data structures with a
hierarchical relationship among its elements known
as nodes.
The bottommost nodes in the hierarchy are
called leaf node while the topmost node is
called root node. Each node contains pointers to
point adjacent nodes.
Tree data structure is based on the parent-child
relationship among the nodes.
Each node in the tree can have more than one
children except the leaf nodes whereas each node
can have atmost one parent except the root node.
14. Graphs: Graphs can be defined as the pictorial
representation of the set of elements.
These elements are represented as vertices
and the vertices are connected by the links
known as edges.
A graph is different from tree in the sense that
a graph can have cycle while the tree can not
have the one.
15. Operations on data structure
1) Traversing: Every data structure contains the set of data
elements. Traversing the data structure means visiting
each element of the data structure in order to perform
some specific operation like searching or sorting.
Example: If we have an array contains a set of numbers.
Each and every element is visited by traversing the
complete array.
2) Insertion: Insertion can be defined as the process of
adding the elements to the data structure at any location.
3) Deletion:The process of removing an element from the
data structure is called Deletion. We can delete an element
from the data structure at any random location.
16. 4) Searching: The process of finding the location of
an element within the data structure is called
Searching.
5) Sorting: The process of arranging the data
structure in a specific order is known as Sorting.
There are many algorithms that can be used to
perform sorting, for example, insertion sort,
selection sort, bubble sort, etc.
6) Merging: When two lists List A and List B of size
M and N respectively, of similar type of elements,
clubbed or joined to produce the third list, List C of
size (M+N), then this process is called merging
20. Array Length
Consider the following array stored in memory.
Let us find the length of this array
Length = UB-LB+1
= 207 – 200 +1 = 8
So the length is 8 ( number of elements)
26. Linear Arrays
• A linear array is a list of a finite number n of
homogeneous data elements.
• The length of data elements of the array can
be obtained by the following formula:
• Length = UB – LB + 1
• UB is upper bound and LB is the lower bound.
27. Algorithm 4.1(Traversing a Linear Array)
• Here LA is a linear array with lower bound LB and
upper bond UB. This algorithm traverses LA
applying an operation PROCESS to each element
of LA.
• 1. [Initialize counter] Set K := LB
• 2. Repeat steps 3 and 4 while K ≤ UB
• 3. [Visit element] Apply PROCESS to LA[K]
• 4. [Increase counter] Set K := K + 1
• 5. [End of Step 2 loop]
28. Algorithm 4.2(Inserting into a Linear Array)
• INSERT(LA, N, K, ITEM)
• Here LA is a linear array with N elements and K
is a positive integer such that K ≤ N. This
algorithm inserts an element ITEM into the
Kth position in LA.
29. Algorithm 4.2(Inserting into a Linear Array)
• 1. [Initialize counter] Set J := N
• 2. Repeat steps 3 and 4 while J ≥ K
• [Move Jth element downward]
• 3. Set LA[J+1] := LA[J]
• 4.[Decrease counter] Set J := J – 1
• [End of Step 2 loop]
• 5. [Insert element] Set LA[K] := ITEM
• 6. [Reset N] Set N := N + 1
• 7. Exit
30. Algorithm 4.3(Deleting from a Linear Array)
• DELETE(LA, N, K, ITEM)
• Here LA is a linear array with N elements and K
is a positive integer such that K ≤ N. this
algorithm deletes the Kth element from LA.
31. Algorithm 4.3(Deleting from a Linear Array)
• 1. Set ITEM := LA[K]
• 2. Repeat steps for J = K to N - 1
• [Move J + 1st element upward]
• Set LA[J] := LA[J + 1]
• [End of Step 2 loop]
• 3. [Reset the number N of elements in LA]
• Set N := N - 1
• 4. Exit
33. Multidimensional Arrays
• The arrays whose elements are accessed by
more than one subscript are termed as
multidimensional arrays.
• Two-Dimensional array
A two dimensional m × n array A is a collection of
m.n data elements such that each element is
specified by a pair of integers (such as J, K)
called subscripts, with the property that1 ≤ J ≤
m and 1 ≤ K ≤ m
The element of A with first subscript j and second
subscript k will be denoted by A[J, K]
35. Column Major Order
• In the column major order, the
elements are stored column by
column. First column, second column
and so on.
number[3][2] in column major order
would look like:
36. Row Major Order
• In the row major order, the elements
are stored row by row. First row,
second row and so on.
number[3][2] in row major order
would look like:
38. Location of an element in Column Major Order:
The formula is:
LOC (A [J, K]) = Base (A) + w [M (K-1) + (J-1)]
Here
LOC (A [J, K]) : is the location of the element in the
Jth row and Kth column.
Base (A) : is the base address of the array A.
w : is the number of bytes required to
store single element of the array A.
M : is the total number of rows in the array.
J : is the row number of the element.
K : is the column number of the element.
39. Location of an element in Row Major Order:
The formula is:
LOC (A [J, K]) = Base (A) + w [N (J-1) + (K-1)]
Here
LOC (A [J, K]) : is the location of the element in the
Jth row and Kth column.
Base (A) : is the base address of the array A.
w : is the number of bytes required to store
single element of the array A.
N : is the total number of columns in the
array.
J : is the row number of the element.
K : is the column number of the element.
41. find the location of A [3, 2]. The required values are:
Base (A) : 1000
w : 2 (because an integer takes 2 bytes in memory)
M : 3
J : 3
K : 2
Now put these values in the given formula as below:
LOC (A [3, 2]) = 1000 + 2 [3 (2-1) + (3-1)]
= 1000 + 2 [3 (1) + 2]
= 1000 + 2 [3 + 2]
= 1000 + 2 [5]
= 1000 + 10
= 1010
43. find the location of A [3, 2]. The required values are:
Base (A) : 1000
w : 2 (because an integer takes 2 bytes in memory)
N : 4
J : 3
K : 2
Now put these values in the given formula as below:
LOC (A [3, 2]) = 1000 + 2 [4 (3-1) + (2-1)]
= 1000 + 2 [4 (2) + 1]
= 1000 + 2 [8 + 1]
= 1000 + 2 [9]
= 1000 + 18
= 1018
44. Records
A record is a collection of related elements, possibly of different
types, having a single name. Each element in a record is called a
field.
A field is the smallest element of named data that has meaning.
A field has a type and exists in memory. Fields can be assigned type
and exists in memory.
Fields can be assigned values, which in turn be accessed for
selection or manipulation.
A field differs from a variable in that it is part of a record
45. Two examples of records.
The first example, fraction, has two fields, both of
which are integers. The second example, student,
has three fields made up of three different types.
47. EXAMPLE 4.17
Suppose a hospital keeps a record of each newborn baby which contains the following
data items: Name, Sex ,Birthday, Father, Mother.
Suppose further that Birthday is a group item with subitems Month, Day and Year, and
Father and Mother are group items, each with subitems Name and Age.
Figure shows how such a record could appear.
48. The structure of the above record is usually described as follows. (Note that Name appears
three times and Age appears twice in the structure
1 Newborn
2 Name
2 Sex
2 Birthday
3 Month
3 Day
3 Year
2 Father
3 Name
3 Age
2 Mother
3 Name
3 Age
49. The number to the Left of each identifier is called a level number.
Observe that each group item is followed by subitems, and the level of the
subitems is I more than the level of the group item.
Furthermore, an item is a group item if and only if it is immediately
followed by an item with a greater level number.
Some of the identifiers in a record structure may also refer to arrays of
elements.
In fact, suppose the first line of the above structure is replaced by
I Newborn(20)
This will indicate a file of 20 records. and the usual subscript notation will
be used to distinguish between different records in the file.
That is, we will write Newborn1, Newborn2 Newborn3, or Newborn[1],
Ncwborn[2], Newborn[3],. to denote different records in the file.
50. EXAMPLE 4.18
A class of student records may be organized as follows:
Student(20)
2 Name
3 Last
3 First
3 Ml (Middle Initial)
2 Test(3)
2 Final
2 Grade
The identifier Student( 20) indicates that there are 20 students. The identifier Test (3) indicates that
there are three tests Per student.
Observe that there are 8 elementary items per Student, since Test is counted 3 times. Altogether,
there are 160 elementary items in the entire Student structure.
Indexing Items in a Record
Suppose we Want to access some data item in a record. In some cases, we cannot simply write the
data name of the item since the same name may appear in different places in the record.
For example Age appears in two places in the record in Example 4.17. Accordingly, in order to specify
a particular item, we may have to qualify the name by using appropriate group item names in the
structure.
This qualification is indicated by using decimal points (periods) to separate group items from
51. EXAMPLE
(a) Consider the record structure Newborn in Example 4.17. Sex and year need no qualification, since each
refer to a unique item in the structure. On the other hand, suppose we want to refer to the age of the
father.
This can be done by writing Newborn. Father. Age or simply Father.Age
The first reference is said to be fully qualified. Sometimes one adds qualifying identifiers for clarity.
(b) Suppose the first line in the record structure in Example 4.17 is replaced by
I Newborn(20)
That is, Newborn is defined to be a file with 20 records. Then every item automatically becomes a 20-
element array.
Some languages allow the sex of the sixth newborn to be referenced by writing Newborn.Sex(6) or
simply Sex[6].
Analogously, the age of the father of the sixth newborn may be referenced by writing Newborn. Father.
Age[6] or simply Father.Agc(6] -