Documente Academic
Documente Profesional
Documente Cultură
ALGORITHMS)
ALGOS IMPLEMENTATION INTO C++
SUBMITTED BY:-
ABID QA DOO S
SUBMITT
ED TO:-
MR. NAUMAN
QADIR SB
Data structure
In programming, the term data structure refers to a scheme for organizing related pieces of
information. The basic types of data structures include:
1. files
2. lists
3. arrays
4. records
5. trees
6. tables
7. Each of these basic structures has many variations and allows different operations to be
performed on the data.
(computer science) A collection of data components that are constructed in a regular and
characteristic way.
data structure
The physical layout of data. Data fields, memo fields, fixed length fields, variable length fields,
records, word processing documents, spreadsheets, data files, database files and indexes are all
examples of data structures.
data structure
Way in which data are stored for efficient search and retrieval. The simplest data structure is the
one-dimensional (linear) array, in which stored elements are numbered with consecutive integers
and contents are accessed by these numbers. Data items stored nonconsecutively in memory may
be linked by pointers (memory addresses stored with items to indicate where the "next" item or
items in the structure are located). Many algorithms have been developed for sorting data
efficiently; these apply to structures residing in main memory and also to structures that
constitute information systems and databases.
array
In programming, a series of objects all of which are the same size and type. Each object in an
array is called an array element. For example, you could have an array of integers or an array of
characters or an array of anything that has a defined data type. The important characteristics of
an array are:
Each element has the same data type (although they may have different values).
• The entire array is stored contiguously in memory (that is, there are no gaps between
elements).
2Arrays can have more than one dimension. A one-dimensional array is
called a vector ; a two-dimensional array is called a matrix.
ar·ray (ə-rā')
tr.v., -rayed, -ray·ing, -rays.
1. To set out for display or use; place in an orderly arrangement: arrayed the whole
regiment on the parade ground.
2. To dress in finery; adorn.
n.
linked list
In data management, a group of items, each of which points to the next item. It allows for the
organization of a sequential set of data in noncontiguous storage locations.
The following code would traverse the list and display names and account balance:
tree structure
A type of data structure in which each element is attached to
one or more elements directly beneath it. The connections
between elements are called branches. Trees are often called
inverted trees because they are normally drawn with the root at
the top.
TABLE
Refers to data arranged in rows and columns. A spreadsheet, for example, is a table. In relational
database management systems, all information is stored in the form of tables.
TRAVERSING
TRAVERSE ( A , LB , N )
Here we have an array “A” with lower bound “ LB” and “N” number of elements. This
algo will perform traversing in array “A”.
INSERTION
Insertion ( A , LB , N , K , ITEM , SIZE )
Here we have an array “A” with its lower bound “LB” and “N” are its no of elements.
“SIZE” is the possible size of array “A”. “ITEM” is the element we want to insert and
“K” is the position where insertion take place. This algo will perform insertion.
Step # 1 IF (( N=SIZE) || (K<LB) || (K>N+LB))
a. DISPLAY(“ INSERTION CAN NOT TAKE PLACE”)
b. EXIT
Step # 2 REPEAT FOR ( I = N+LB-1 DOWN TO K)
a. A[I+1]=A[I]
b. A[K]=ITEM
Step # 3 N=N+1
Step # 4 EXIT
DELETION
DELETION ( A , LB , N , K , ITEM )
Here we have an array “A” with its lower bound “LB” and “N” are its no of elements.
“SIZE” is the possible size of array “A”. “ITEM” is the element we want to delete and
“K” is the position where deletion take place. This algo will perform deletion.
Step # 1 IF ((K<LB) || (K>N+LB-1))
c. DISPLAY(“ DELETION CAN NOT TAKE PLACE”)
d. EXIT
Step # 2 ITEM = A[K]
Step # 3 REPEAT FOR ( I = ( K + 1) TO N+LB-1)
c. A[I-1]=A[I]
Step # 4 N=N-1
Step # 5 EXIT
SEARCHING
Step # 1 LAST = N + LB – 1
Step # 2 REPEAT FOR ( I= 1 TO N-1)
a REPEAT FOR ( J = LAB TO LAST – 1 )
IF ( A[J]> A[J+1])
A[J] A [J+1]
b LAST = LAST – 1
Step # 3 EXIT
SELECTION SORT
SELECTION_SORT ( A , LB , N )
Here we have an array “A” with its lower bound “LB” and “N” number of elements. This
algo will perform selection sorting in array “A”.
Step # 1. REPEAT FOR ( I = LB TO N + LB -1 )
a MINLOC = I
b REPEAT FOR ( J = I + 1 TO N + LAB - 1 )
i. IF ( A[MINLOC] > A [ J ] )
ii. MINLOC =J
C A[ I ] A[MINLOC]
Step # 2 EXIT
SHELL SORT
SHELL_SORT(A,LB,N)
Here we have an array “A” with lower bound “ LB” and “N” number of elements. This
(c) EXCHANGE 0
1. EXHANGE 0
ii. EXCHANGE 1
(e) GAP=INT(GAP/2)
STEP # 3 EXIT
INSERTION SORT
INSERTION_SORT (A,LB,N)
Here we have an array “A” with lower bound “ LB” and “N” number of elements. This
1. A[PTR + 1] A[PTR]
2. PTR PTR - 1
STEP # 2 EXIT
STEP # 1. IF (START=NULL)
a) LINK LIST EMPTY
b) EXIT.
STEP #2. PTR START
STEP #3 WHILE (PTR#NULL)
a) PROCESS (PTR->INFO)
b) PTRPTR->NEXT
STEP #4 EXIT.
2. INSERTION AT FIRST
DELETION
6. AT FIRST NODE
8. TRAVERSING FORWARD
STEP # 1. IF (START=NULL)
a) LINK LIST EMPTY
b) EXIT.
STEP #2. PTR START
STEP #3 WHILE (PTR#NULL)
a) PROCESS (PTR->INFO)
b) PTRPTR->NEXT
STEP #4 EXIT.
9. TRAVERSING BACKWARD
STEP # 1. IF (START=NULL)
a) LINK LIST EMPTY
b) EXIT.
STEP #2. PTR START
STEP #3 WHILE (PTR#NULL)
a) PTRPTR->NEXT
STEP # 4 PTR1START
STEP #5 REPEAT WHILE (PTR1->BACK #NULL)
a) PROCESS PTR1->INFO
b) PTR1PTR->BACK
STEP #4 EXIT.
10. INSERTION AT LAST
DELETION
11. AT LAST NODE