Classification s of Data Structures
|
|
- Dora Hamilton
- 5 years ago
- Views:
Transcription
1 Linear Data Structures using Sequential organization
2 Classification s of Data Structures
3 Types of Data Structures
4 Arrays Declaration of arrays type arrayname [ arraysize ]; Ex-double balance[10];
5 Arrays Initializing Arrays Ex-double balance[5] = {1000.0, 2.0, 3.4, 7.0, 50.0}; If you omit the size of the array, an array just big enough to hold the initialization is created. Therefore, if you write Ex-double balance[] = {1000.0, 2.0, 3.4, 7.0, 50.0};
6 Arrays Initializing Arrays Ex-double balance[5] = {1000.0, 2.0, 3.4, 7.0, 50.0}; If you omit the size of the array, an array just big enough to hold the initialization is created. Therefore, if you write Ex-double balance[] = {1000.0, 2.0, 3.4, 7.0, 50.0};
7 Arrays Initializing Arrays You will create exactly the same array as you did in the previous example. Following is an example to assign a single element of the array Ex-balance[4] = 50.0;
8 Arrays Shown below is the pictorial representation of the array:
9 Accessing Array Elements double salary = balance[4];
10 #include <stdio.h> Ex-Arrays int main () { int a[10],i,size; printf( \nhow many no of elements u want to scan ); scanf( %d,&size); printf( \nenter the elements in the array ); for(i=0;i<size;i++) {
11 Output will be
12 Multi-dimensional Arrays in C type name[size1][size2]...[sizen];
13 Two-dimensional Arrays in C multidimensional array is the two-dimensional array type arrayname [ x ][ y ];
14 Two-dimensional Arrays in C
15 Initializing Two-Dimensional Arrays int a[3][4] = { {0, 1, 2, 3}, /* initializers for {4, 5, 6, 7}, {8, 9, 10, 11} /* initializers for row /* initializers for row indexed by 2 */ };
16 Accessing Two-Dimensional Array Elements int val = a[2][3];
17 Three-dimensional Arrays in C For example, the following declaration creates a three dimensional integer array Ex-int threedim[5][10][4];
18 Passing Arrays as Function Arguments in C void myfunction(int param[10]) {... //Statement Excution }
19 Abstract Data Type ADT is useful tool for specifying the logical properties of a data type. A data type is a collection of values & the set of operations on the values. ADT refers to the mathematical concept that defines the data type. ADT is not concerned with implementation but is useful in making use of data type.
20 ADT for an array Arrays are stored in consecutive set of memory locations. Array can be thought of as set of index and values. For each index which is defined there is a value associated with that index. There are two operations permitted on array data structure.retrieve and store
21 ADT for an array CREATE()-produces empty array. RETRIVE(array,index)->value Takes as input array and index and either returns appropriate value or an error. STORE(array,index,value)-array used to enter new index value pairs.
22 Introduction to arrays Representation and analysis Type variable_name[size] Operations with arrays: Copy Delete Insert Search Sort Merging of sorting arrays.
23 #include <stdio.h> int main() { int a[100],b[100] position, c, n; Copy operation printf("enter number of elements in array\n");
24 Output Enter number of elements in array -4 Enter 4 elements displaying array a 1
25 #include <stdio.h> int main() { int array[100], position, c, n; printf("enter number of elements in array\n"); scanf("%d", &n); printf("enter %d elements\n", n); Delete operation for ( c = 0 ; c < n ; c++ )
26 Delete operation
27 Inserting an element #include <stdio.h> int main() { int array[100], position, c, n, value; printf("enter number of elements in array\n"); scanf("%d", &n); printf("enter %d elements\n", n); for (c = 0; c < n; c++)
28 Inserting an element
29 Sort an array Int a[10]={5,4,3,2,1} for(i=0;i<n;i++) for(j=i+1;j<n-i;j++) { if(a[i]>a[j]) { temp=a[i]; a[i]=a[j]; a[j]=temp; }
30 Reverse array a[6]={11,12,13,14,15,16} J=n-1; For(i=0;i<n/2;i++) { temp=a[i]; a[i]=a[j]; a[j]=temp; j--; }
31 Sort element using array Int a[10]={5,4,3,2,1} for(i=0;i<n;i++) for(j=i+1;j<n;j++) { if(a[i]>a[j]) { temp=a[i]; a[i]=a[j]; a[j]=temp; }
32 Merging of two arrays int main() { int arr1[30], arr2[30], res[60]; int i, j, k, n1, n2; printf("\nenter no of
33 Merging of two arrays // Merging starts while (i < n1 && j < n2) { if (arr1[i] <= arr2[j]) { res[k] = arr1[i]; i++;
34 Merging of two arrays /* Some elements in array 'arr1' are still remaining where as the array 'arr2' is exhausted */ while (i < n1) { res[k] = arr1[i]; i++; k++; }
35 Merging of two arrays /* Some elements in array 'arr2' are still remaining where as the array 'arr1' is exhausted */ while (j < n2) { res[k] = arr2[j]; k++; j++; }
36 Merging of two arrays //Displaying elements of array 'res' printf("\nmerged array is :"); for (i = 0; i < n1 + n2; i++) printf("%d ", res[i]); return (0); }
37 Merging of two arrays /* Some elements in array 'arr2' are still remaining where as the array 'arr2' is exhausted */ while (i < n2) { res[k] = arr2[i]; i++; k++; } for(i=0;i<k;i++) { printf( %d,res[i]); }
38 Merging of two arrays Output: Enter no of elements in 1st array : Enter no of elements in 2nd array : Merged array is :
39 Merging of two arrays
40 Two-dimensional Arrays in C multidimensional array is the two-dimensional array type arrayname [ x ][ y ];
41 Two-dimensional Arrays in C
42 m-no of rows n-no of columns Printf( \n Enter the rows and columns ); Scanf(%d %d,&m,&n); for(i=0;i<m;i++) { for(j=0;j<n;j++) { Printf( \n Enter the value of(%d)(%d)=,i,j); Scanf( %d,&a[i][j]); }
43 For(i=0;i<m;i++) { Printf( \n ); For(j=0;j<n;j++) { printf( %d,&a[i][j]); } }
44 int main () { /* an array with 5 rows and 2 columns*/ int a[5][2] = { {0,0}, {1,2}, {2,4}, {3,6},{4,8}}; int i, j; /* output each array element's value */ for ( i = 0; i < 5; i++ ) { for ( j = 0; j < 2; j++ ) { printf("a[%d][%d] = %d\n", i,j, a[i][j] ); } } return 0; }
45 Address Calculation in single (one) Dimension Array:
46 Address Calculation
47 Address Calculation Array of an element of an array say A[ I ] is calculated using the following formula: Address of A [ I ] = B + W * ( I LB ) Where, B = Base address W = Storage Size of one element stored in the array (in byte) I = Subscript of element whose address is to be found LB = Lower limit / Lower Bound of subscript, if not specified assume 0 (zero)
48 Address Calculation Ex-Given the base address of an array B[ ] as 1020 and size of each element is 2 bytes in the memory. Find the address of B[1700]. Solution: The given values are: B = 1020, LB = 1300, W = 2, I = 1700 Address of A [ I ] = B + W * ( I LB ) = * ( ) = * 400 =
49 Address Calculation in Double (Two) Dimensional Array: While storing the elements of a 2-D array in memory, these are allocated contiguous memory locations. Therefore, a 2-D array must be liberalized so as to enable their storage. There are two alternatives to achieve linearization: Row-Major and Column-Major.
50 Address Calculation in Double (Two) Dimensional Array:
51 Address Calculation in Double (Two) Dimensional Array:
52 Address Calculation in Double (Two) Dimensional Array: Address of an element of any array say A[ I ][ J ] is calculated in two forms as given: (1) Row Major System (2) Column Major System
53 Address Calculation in Double (Two) Dimensional Array: The address of a location in Row Major System is calculated using the following formula: Address of A [ I ][ J ] = B + W * [ N * ( I Lr ) + ( J Lc ) B = Base address I = Row subscript of element whose address is to be found J = Column subscript of element whose address is to be found W = Storage Size of one element stored in the array (in byte) Lr = Lower limit of row/start row index of matrix, if not given assume 0 (zero) Lc = Lower limit of column/start column index of matrix, if not given assume 0 (zero) M = Number of row of the given matrix N = Number of column of the given matrix
54 Address Calculation in Double (Two) Dimensional Array: Column Major System: The address of a location in Column Major System is calculated using the following formula: Address of A [ I ][ J ] Column Major Wise = B + W * [( I Lr ) + M * ( J Lc )] B = Base address I = Row subscript of element whose address is to be found J = Column subscript of element whose address is to be found W = Storage Size of one element stored in the array (in byte) Lr = Lower limit of row/start row index of matrix, if not given assume 0 (zero) Lc = Lower limit of column/start column index of matrix, if not given assume 0 (zero)
55 Address Calculation in Double (Two) Dimensional Array: Important : Usually number of rows and columns of a matrix are given ( like A[20][30] or A[40][60] ) but if it is given as A[Lr- Ur, Lc- Uc]. In this case number of rows and columns are calculated using the following methods: Number of rows (M) will be calculated as = (Ur Lr) + 1 Number of columns (N) will be calculated as = (Uc Lc) + 1 And rest of the process will remain same as per requirement (Row Major Wise or Column Major Wise).
56 Address Calculation in Double (Two) Dimensional Array: Examples: Q 1. An array X [-15.10, 15 40] requires one byte of storage. If beginning location is 1500 determine the location of X [15][20]. Solution: As you see here the number of rows and columns are not given in the question. So they are calculated as: Number or rows say M = (Ur Lr) + 1 = [10 (- 15)] +1 = 26 Number or columns say N = (Uc Lc) + 1 = [40 15)] +1 = 26
57 Address Calculation in Double (Two) Dimensional Array: (i) Column Major Wise Calculation of above equation The given values are: B = 1500, W = 1 byte, I = 15, J = 20, Lr = -15, Lc = 15, M = 26 Address of A [ I ][ J ] =B + W * [ ( I Lr ) + M * ( J Lc ) ] = * [(15 (-15)) + 26 * (20 15)] = * [ * 5] = * [160] = 1660 [Ans]
58 (ii) Row Major Wise Calculation of above equation The given values are: B = 1500, W = 1 byte, I = 15, J = 20, Lr = -15, Lc = 15, N = 26 Address of A [ I ][ J ] = B + W * [ N * ( I Lr ) + ( J Lc ) ] = * [26 * (15 (-15))) + (20 15)] = * [26 * ] = * [ ] = = 2285 [Ans]
59 Addition of Two 2-D Matrices: If we add two matrices am*n & bm*n Cm*n producing for(i=0;i<m;i++) //for row { for(j=0;j<n;j++) //for column { c[i][j]=a[i][j]+b[i][j]; } }
60 Upper Triangular Matrix A triangular matrix of the form Written explicitly,
61 Example #include<stdio.h> #include<conio.h> void main() { int a[3][3],i,j; clrscr(); printf("enter the elements of 3x3 matrix:\n"); for(i=0;i<3;i++) { { for(j=0;j<3;j++) scanf("%d",&a[i][j]); } }
62 Strictly Upper Triangular Matrix A strictly upper triangular matrix is an upper triangular matrix having 0s along the diagonal as well as the lower portion, i.e., a matrix such that for. Written explicitly,
63 Lower Triangular Matrix A triangular matrix L of the form Written explicitly,
64 Strictly Lower Triangular Matrix A lower triangular matrix having 0s along the diagonal as well as the upper portion, i.e., a matrix such that for. Written explicitly,
65 Assignment on Strictly Upper Triangular Matrix Strictly Lower Triangular Matrix
66 MULTIPLICATION OF TWO MATRICES For example: Suppose two matrixes A and B of size of 2 x 2 and 2 x 3 respectively:
67
68 Transpose of a Matrix A matrix which is formed by turning all the rows of a given matrix into columns and vice-versa. The transpose of matrix A is written AT.
69 Concept of Ordered List It is a set of elements.such a list sometimes called as linear list. Definition- EX-1.List of one one digit numbers. (0,1,2,3,4,5,6,7,8,9) Ex-2 Days in a week. (Sunday, Monday Tuesday, Wednesday, Thursday,Friday,Saturday)
70 Operations on ordered list Create an ordered list Dispay of list Searching particular element from the list Insertion of any element in the list Deletion of any element from the list
71 Example of ordered list Polynomial Operations
72 While scanning the string doesn t required scanf( %s,str1) ; scanf needs the address of the variable to read into, and string buffers are already represented as addresses (pointer to a location in memory, or an array that decomposes into a pointer). printf does the same, treating %s as a pointer-to-string.
73 Scanning string scanf needs the address of the variable to read into, and string buffers are already represented as addresses (pointer to a location in memory, or an array that decomposes into a pointer). printf does the same, treating %s as a pointer-to-string.
Computer Programming. C Array is a collection of data belongings to the same data type. data_type array_name[array_size];
Arrays An array is a collection of two or more adjacent memory cells, called array elements. Array is derived data type that is used to represent collection of data items. C Array is a collection of data
More informationLecture (07) Arrays. By: Dr. Ahmed ElShafee. Dr. Ahmed ElShafee, ACU : Fall 2015, Programming I
Lecture (07) Arrays By: Dr Ahmed ElShafee ١ introduction An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type Instead
More informationArrays. Arrays are of 3 types One dimensional array Two dimensional array Multidimensional array
Arrays Array is a collection of similar data types sharing same name or Array is a collection of related data items. Array is a derived data type. Char, float, int etc are fundamental data types used in
More informationUNIT 2 ARRAYS 2.0 INTRODUCTION. Structure. Page Nos.
UNIT 2 ARRAYS Arrays Structure Page Nos. 2.0 Introduction 23 2.1 Objectives 24 2.2 Arrays and Pointers 24 2.3 Sparse Matrices 25 2.4 Polynomials 28 2.5 Representation of Arrays 30 2.5.1 Row Major Representation
More informationUnit 1 - Arrays. 1 What is an array? Explain with Example. What are the advantages of using an array?
1 What is an array? Explain with Example. What are the advantages of using an array? An array is a fixed-size sequenced collection of elements of the same data type. An array is derived data type. The
More informationCSE101-Lec#18. Multidimensional Arrays Application of arrays. Created By: Amanpreet Kaur & Sanjeev Kumar SME (CSE) LPU. LPU CSE101 C Programming
CSE101-Lec#18 Multidimensional Arrays Application of arrays Created By: Amanpreet Kaur & Sanjeev Kumar SME (CSE) LPU Outline Defining and processing 1D array 2D array Applications of arrays 1-D array A
More informationTo declare an array in C, a programmer specifies the type of the elements and the number of elements required by an array as follows
Unti 4: C Arrays Arrays a kind of data structure that can store a fixed-size sequential collection of elements of the same type An array is used to store a collection of data, but it is often more useful
More informationArrays and Strings. Arash Rafiey. September 12, 2017
September 12, 2017 Arrays Array is a collection of variables with the same data type. Arrays Array is a collection of variables with the same data type. Instead of declaring individual variables, such
More informationCS11001/CS11002 Programming and Data Structures (PDS) (Theory: 3-1-0) Introduction to arrays
CS11001/CS11002 Programming and Data Structures (PDS) (Theory: 3-1-0) Introduction to arrays 1 What are Arrays? Arrays are our first example of structured data. Think of a book with pages numbered 1,2,...,400.
More informationARRAYS(II Unit Part II)
ARRAYS(II Unit Part II) Array: An array is a collection of two or more adjacent cells of similar type. Each cell in an array is called as array element. Each array should be identified with a meaningful
More informationModule 6: Array in C
1 Table of Content 1. Introduction 2. Basics of array 3. Types of Array 4. Declaring Arrays 5. Initializing an array 6. Processing an array 7. Summary Learning objectives 1. To understand the concept of
More informationF.Y. Diploma : Sem. II [CO/CD/CM/CW/IF] Programming in C
F.Y. Diploma : Sem. II [CO/CD/CM/CW/IF] Programming in C Time : 3 Hrs.] Prelim Question Paper Solution [Marks : 70 Q.1 Attempt any FIVE of the following : [10] Q.1 (a) List any four relational operators.
More informationAPS105. Collecting Elements 10/20/2013. Declaring an Array in C. How to collect elements of the same type? Arrays. General form: Example:
Collecting Elements How to collect elements of the same type? Eg:., marks on assignments: APS105 Arrays Textbook Chapters 6.1-6.3 Assn# 1 2 3 4 5 6 Mark 87 89 77 96 87 79 Eg: a solution in math: x 1, x
More informationUNIT-1. Chapter 1(Introduction and overview) 1. Asymptotic Notations 2. One Dimensional array 3. Multi Dimensional array 4. Pointer arrays.
UNIT-1 Chapter 1(Introduction and overview) 1. Asymptotic Notations 2. One Dimensional array 3. Multi Dimensional array 4. Pointer arrays. Chapter 2 (Linked lists) 1. Definition 2. Single linked list 3.
More informationUNIT III ARRAYS AND STRINGS
UNIT III ARRAYS AND STRINGS Arrays Initialization Declaration One dimensional and Two dimensional arrays. String- String operations String Arrays. Simple programs- sorting- searching matrix operations.
More informationHow to declare an array in C?
Introduction An array is a collection of data that holds fixed number of values of same type. It is also known as a set. An array is a data type. Representation of a large number of homogeneous values.
More informationWhat is recursion. WAP to find sum of n natural numbers using recursion (5)
DEC 2014 Q1 a What is recursion. WAP to find sum of n natural numbers using recursion (5) Recursion is a phenomenon in which a function calls itself. A function which calls itself is called recursive function.
More informationIn the previous lecture, we learned about how to find the complexity of algorithms and search algorithms on array.
Lecture 2 What we will learn 1. Definition of Arrays 2. Representation of Arrays in memory 3. Row-major Order and Column-major Order In the previous lecture, we learned about how to find the complexity
More informationGovernment Polytechnic Muzaffarpur.
Government Polytechnic Muzaffarpur. Name of the Lab: COMPUTER PROGRAMMING LAB (MECH. ENGG. GROUP) Subject Code: 1625408 Experiment: 1 Aim: Programming exercise on executing a C program. If you are looking
More information'C' Programming Language
F.Y. Diploma : Sem. II [DE/EJ/ET/EN/EX] 'C' Programming Language Time: 3 Hrs.] Prelim Question Paper Solution [Marks : 70 Q.1 Attempt any FIVE of the following : [10] Q.1(a) Define pointer. Write syntax
More informationAn array is a collection of data that holds fixed number of values of same type. It is also known as a set. An array is a data type.
Data Structures Introduction An array is a collection of data that holds fixed number of values of same type. It is also known as a set. An array is a data type. Representation of a large number of homogeneous
More informationQ 1. Attempt any TEN of the following:
Subject Code: 17212 Model Answer Page No: 1 / 26 Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given in the model answer scheme. 2) The
More informationContents ARRAYS. Introduction:
UNIT-III ARRAYS AND STRINGS Contents Single and Multidimensional Arrays: Array Declaration and Initialization of arrays Arrays as function arguments. Strings: Initialization and String handling functions.
More informationWrite a C program using arrays and structure
03 Arrays and Structutes 3.1 Arrays Declaration and initialization of one dimensional, two dimensional and character arrays, accessing array elements. (10M) 3.2 Declaration and initialization of string
More informationArrays. CS10001: Programming & Data Structures. Pallab Dasgupta Dept. of Computer Sc. & Engg., Indian Institute of Technology Kharagpur
Arrays CS10001: Programming & Data Structures Pallab Dasgupta Dept. of Computer Sc. & Engg., Indian Institute of Technology Kharagpur Array Many applications require multiple data items that have common
More informationUnit 3 Decision making, Looping and Arrays
Unit 3 Decision making, Looping and Arrays Decision Making During programming, we have a number of situations where we may have to change the order of execution of statements based on certain conditions.
More informationFUNCTIONS OMPAL SINGH
FUNCTIONS 1 INTRODUCTION C enables its programmers to break up a program into segments commonly known as functions, each of which can be written more or less independently of the others. Every function
More informationC Language Part 2 Digital Computer Concept and Practice Copyright 2012 by Jaejin Lee
C Language Part 2 (Minor modifications by the instructor) 1 Scope Rules A variable declared inside a function is a local variable Each local variable in a function comes into existence when the function
More informationEM108 Software Development for Engineers
EE108 Section 2 Arrays page 1 of 19 EM108 Software Development for Engineers Section 2 - Arrays 1) Introduction 2) Definition 3) Using Arrays 4) Array Initialisation 5) Searching Within Arrays 6) Array
More informationF.E. Sem. II. Structured Programming Approach
F.E. Sem. II Structured Programming Approach Time : 3 Hrs.] Mumbai University Examination Paper Solution - May 14 [Marks : 80 Q.1(a) What do you mean by algorithm? Which points you should consider [4]
More informationC library = Header files + Reserved words + main method
DAY 1: What are Libraries and Header files in C. Suppose you need to see an Atlas of a country in your college. What do you need to do? You will first go to the Library of your college and then to the
More informationTo store the total marks of 100 students an array will be declared as follows,
Chapter 4 ARRAYS LEARNING OBJECTIVES After going through this chapter the reader will be able to declare and use one-dimensional and two-dimensional arrays initialize arrays use subscripts to access individual
More informationArrays. Dr. Madhumita Sengupta. Assistant Professor IIIT Kalyani
Arrays Dr. Madhumita Sengupta Assistant Professor IIIT Kalyani INTRODUCTION An array is a collection of similar data s / data types. The s of the array are stored in consecutive memory locations and are
More informationPROGRAMMING IN C LAB MANUAL FOR DIPLOMA IN ECE/EEE
PROGRAMMING IN C LAB MANUAL FOR DIPLOMA IN ECE/EEE 1. Write a C program to perform addition, subtraction, multiplication and division of two numbers. # include # include int a, b,sum,
More informationMulti-Dimensional arrays
Multi-Dimensional arrays An array having more then one dimension is known as multi dimensional arrays. Two dimensional array is also an example of multi dimensional array. One can specify as many dimensions
More informationProgramming in C Lab
Programming in C Lab 1a. Write a program to find biggest number among given 3 numbers. ALGORITHM Step 1 : Start Start 2 : Input a, b, c Start 3 : if a > b goto step 4, otherwise goto step 5 Start 4 : if
More informationArray. Arrays. Declaring Arrays. Using Arrays
Arrays CS215 Peter Lo 2004 1 Array Array Group of consecutive memory locations Same name and type To refer to an element, specify Array name Position number Format: arrayname[ position number] First element
More informationArrays. CS10001: Programming & Data Structures. Pallab Dasgupta Dept. of Computer Sc. & Engg., Indian Institute of Technology Kharagpur
Arrays CS10001: Programming & Data Structures Pallab Dasgupta Dept. of Computer Sc. & Engg., Indian Institute of Technology Kharagpur 1 Array Many applications require multiple data items that have common
More informationArrays a kind of data structure that can store a fixedsize sequential collection of elements of the same type. An array is used to store a collection
Morteza Noferesti Arrays a kind of data structure that can store a fixedsize sequential collection of elements of the same type. An array is used to store a collection of data, but it is often more useful
More informationPESIT Bangalore South Campus Hosur road, 1km before Electronic City, Bengaluru -100 Department of Basic Science and Humanities
PESIT Bangalore South Campus Hosur road, 1km before Electronic City, Bengaluru -100 Department of Basic Science and Humanities Continuous Internal Evaluation Test 2 Date: 0-10- 2017 Marks: 0 Subject &
More informationMAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified) MODEL ANSWER
Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given in the model answer scheme. 2) The model answer and the answer written by candidate
More informationArrays. Elementary Data Representation Different Data Structure Operation on Data Structure Arrays
Arrays Elementary Data Representation Different Data Structure Operation on Data Structure Arrays Elementary Data Representation Data can be in the form of raw data, data items and data structure. Raw
More informationMODULE 1. Introduction to Data Structures
MODULE 1 Introduction to Data Structures Data Structure is a way of collecting and organizing data in such a way that we can perform operations on these data in an effective way. Data Structures is about
More informationLecture 5: Multidimensional Arrays. Wednesday, 11 February 2009
Lecture 5: Multidimensional Arrays CS209 : Algorithms and Scientific Computing Wednesday, 11 February 2009 CS209 Lecture 5: Multidimensional Arrays 1/20 In today lecture... 1 Let s recall... 2 Multidimensional
More informationIntroduction to Arrays
Introduction to Arrays One Dimensional Array. Two Dimensional Array. Inserting Elements in Array. Reading Elements from an Array. Searching in Array. Sorting of an Array. Merging of 2 Arrays. What is an
More informationTwo Dimensional Arrays
2-d Arrays 1 Two Dimensional Arrays We have seen that an array variable can store a list of values Many applications require us to store a table of values Student 1 Student 2 Student 3 Student 4 Subject
More informationTypes of Data Structures
DATA STRUCTURES material prepared by: MUKESH BOHRA Follow me on FB : http://www.facebook.com/mukesh.sirji4u The logical or mathematical model of data is called a data structure. In other words, a data
More informationArrays. Example: Run the below program, it will crash in Windows (TurboC Compiler)
1 Arrays General Questions 1. What will happen if in a C program you assign a value to an array element whose subscript exceeds the size of array? A. The element will be set to 0. B. The compiler would
More informationDownloaded from
Unit-II Data Structure Arrays, Stacks, Queues And Linked List Chapter: 06 In Computer Science, a data structure is a particular way of storing and organizing data in a computer so that it can be used efficiently.
More informationINDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR Stamp / Signature of the Invigilator
INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR Stamp / Signature of the Invigilator EXAMINATION ( Mid Semester ) SEMESTER ( Autumn ) Roll Number Section Name Subject Number C S 1 0 0 0 1 Subject Name Programming
More informationProgram. SUBJECT: ACP (C - Programming) Array Program. // Find the minimum number from given N element. Prepared By : Dhaval R.
Program // Find the minimum number from given N element. #include #include void main() int a[50],i,n,min; clrscr(); printf("\n Enter array size : "); scanf("%d",&n); printf("\n Enter
More informationArrays in C. By Mrs. Manisha Kuveskar.
Arrays in C By Mrs. Manisha Kuveskar. C Programming Arrays An array is a collection of data that holds fixed number of values of same type. For example: if you want to store marks of 100 students, you
More informationSubject: Fundamental of Computer Programming 2068
Subject: Fundamental of Computer Programming 2068 1 Write an algorithm and flowchart to determine whether a given integer is odd or even and explain it. Algorithm Step 1: Start Step 2: Read a Step 3: Find
More informationNCS 301 DATA STRUCTURE USING C
NCS 301 DATA STRUCTURE USING C Unit-1 Part-3 Arrays Hammad Mashkoor Lari Assistant Professor Allenhouse Institute of Technology www.ncs301ds.wordpress.com Introduction Array is a contiguous memory of homogeneous
More informationIntroduction to Programming in C Department of Computer Science and Engineering. Lecture No. #43. Multidimensional Arrays
Introduction to Programming in C Department of Computer Science and Engineering Lecture No. #43 Multidimensional Arrays In this video will look at multi-dimensional arrays. (Refer Slide Time: 00:03) In
More informationMODULE 3: Arrays, Functions and Strings
MODULE 3: Arrays, Functions and Strings Contents covered in this module I. Using an Array II. Functions in C III. Argument Passing IV. Functions and Program Structure, locations of functions V. Function
More informationLecture 2 Arrays, Searching and Sorting (Arrays, multi-dimensional Arrays)
Lecture 2 Arrays, Searching and Sorting (Arrays, multi-dimensional Arrays) In this lecture, you will: Learn about arrays Explore how to declare and manipulate data into arrays Understand the meaning of
More informationSTRUCTURED DATA TYPE ARRAYS IN C++ ONE-DIMENSIONAL ARRAY TWO-DIMENSIONAL ARRAY
STRUCTURED DATA TYPE ARRAYS IN C++ ONE-DIMENSIONAL ARRAY TWO-DIMENSIONAL ARRAY Objectives Declaration of 1-D and 2-D Arrays Initialization of arrays Inputting array elements Accessing array elements Manipulation
More informationAn array is a collection of similar elements that is all the elements in an array should have same data type. This means that an array can store
An array is a collection of similar elements that is all the elements in an array should have same data type. This means that an array can store either all integers, all floating point numbers, all characters,
More informationPDS Class Test 2. Room Sections No of students
PDS Class Test 2 Date: October 27, 2016 Time: 7pm to 8pm Marks: 20 (Weightage 50%) Room Sections No of students V1 Section 8 (All) Section 9 (AE,AG,BT,CE, CH,CS,CY,EC,EE,EX) V2 Section 9 (Rest, if not
More informationMaltepe University Computer Engineering Department. BİL 133 Algoritma ve Programlama. Chapter 8: Arrays and pointers
Maltepe University Computer Engineering Department BİL 133 Algoritma ve Programlama Chapter 8: Arrays and pointers Basics int * ptr1, * ptr2; int a[10]; ptr1 = &a[2]; ptr2 = a; // equivalent to ptr2 =
More informationITC213: STRUCTURED PROGRAMMING. Bhaskar Shrestha National College of Computer Studies Tribhuvan University
ITC213: STRUCTURED PROGRAMMING Bhaskar Shrestha National College of Computer Studies Tribhuvan University Lecture 10: Arrays Readings: Chapter 9 Introduction Group of same type of variables that have same
More informationMaltepe University Computer Engineering Department. BİL 133 Algorithms and Programming. Chapter 8: Arrays
Maltepe University Computer Engineering Department BİL 133 Algorithms and Programming Chapter 8: Arrays What is an Array? Scalar data types use a single memory cell to store a single value. For many problems
More informationCS T35 DATA STRUCTURES
CS T35 DATA STRUCTURES Introduction: Algorithmic notation Programming principles Creating programs- Analyzing programs. Arrays: One dimensional array, multidimensional array, pointer arrays. Searching:
More information2-D Arrays. Of course, to set each grid location to 0, we have to use a loop structure as follows (assume i and j are already defined):
2-D Arrays We define 2-D arrays similar to 1-D arrays, except that we must specify the size of the second dimension. The following is how we can declare a 5x5 int array: int grid[5][5]; Essentially, this
More informationProgramming for Electrical and Computer Engineers. Pointers and Arrays
Programming for Electrical and Computer Engineers Pointers and Arrays Dr. D. J. Jackson Lecture 12-1 Introduction C allows us to perform arithmetic addition and subtraction on pointers to array elements.
More informationCS11001/CS11002 Programming and Data Structures (PDS) (Theory: 3-0-0)
CS11001/CS11002 Programming and Data Structures (PDS) (Theory: 3-0-0) Class Teacher: Pralay Mitra Department of Computer Science and Engineering Indian Institute of Technology Kharagpur Conceptual Idea
More informationFunctions. Arash Rafiey. September 26, 2017
September 26, 2017 are the basic building blocks of a C program. are the basic building blocks of a C program. A function can be defined as a set of instructions to perform a specific task. are the basic
More informationOutline Introduction Arrays Declaring Arrays Examples Using Arrays Passing Arrays to Functions Sorting Arrays
Arrays Outline 1 Introduction 2 Arrays 3 Declaring Arrays 4 Examples Using Arrays 5 Passing Arrays to Functions 6 Sorting Arrays 7 Case Study: Computing Mean, Median and Mode Using Arrays 8 Searching Arrays
More informationComputer Science & Engineering 150A Problem Solving Using Computers
Computer Science & Engineering 150A Problem Solving Using Computers Lecture 06 - Stephen Scott Adapted from Christopher M. Bourke 1 / 30 Fall 2009 Chapter 8 8.1 Declaring and 8.2 Array Subscripts 8.3 Using
More informationFundamental of Programming (C)
Borrowed from lecturer notes by Omid Jafarinezhad Fundamental of Programming (C) Lecturer: Vahid Khodabakhshi Lecture 8 Array typical problems, Search, Sorting Department of Computer Engineering Outline
More informationSingle Dimension Arrays
ARRAYS Single Dimension Arrays Array Notion of an array Homogeneous collection of variables of same type. Group of consecutive memory locations. Linear and indexed data structure. To refer to an element,
More informationSaini Technologies ADVANCED C PROGRAMMING WITH SAINI TECHNOLOGIES. Sushil Kumar Saini Mo.
Saini Technologies ADVANCED C PROGRAMMING WITH SAINI TECHNOLOGIES Sushil Kumar Saini Email: Sushilsaini04@gmail.com Mo. 9896470047 Integer Array int a[]=12,34,54,45,34,34; printf("%d",a[0]); printf(" %d",a[1]);
More informationContent. In this chapter, you will learn:
ARRAYS & HEAP Content In this chapter, you will learn: To introduce the array data structure To understand the use of arrays To understand how to define an array, initialize an array and refer to individual
More informationFOR Loop. FOR Loop has three parts:initialization,condition,increment. Syntax. for(initialization;condition;increment){ body;
CLASSROOM SESSION Loops in C Loops are used to repeat the execution of statement or blocks There are two types of loops 1.Entry Controlled For and While 2. Exit Controlled Do while FOR Loop FOR Loop has
More informationMAHALAKSHMI ENGINEERING COLLEGE B TIRUCHIRAPALLI
MAHALAKSHMI ENGINEERING COLLEGE B TIRUCHIRAPALLI 621213 DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING Sub code: CS2203 SEM: III Sub Name: Object Oriented Programming Year: II UNIT-I PART-A 1. What is
More informationONE DIMENSIONAL ARRAYS
LECTURE 14 ONE DIMENSIONAL ARRAYS Array : An array is a fixed sized sequenced collection of related data items of same data type. In its simplest form an array can be used to represent a list of numbers
More informationINDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR Stamp / Signature of the Invigilator
INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR Stamp / Signature of the Invigilator EXAMINATION ( Mid Semester ) SEMESTER ( Autumn ) Roll Number Section Name Subject Number C S 1 0 0 0 1 Subject Name Programming
More informationAE52/AC52/AT52 C & Data Structures JUNE 2014
Q.2 a. Write a program to add two numbers using a temporary variable. #include #include int main () int num1, num2; clrscr (); printf( \n Enter the first number : ); scanf ( %d, &num1);
More informationProcedural Programming
Universität Duisburg-Essen PRACTICAL TRAINING TO THE LECTURE Procedural Programming Session Five: Arrays Name: First Name: Tutor: Matriculation-Number: Group-Number: Date: Prof. Dr.Ing. Axel Hunger Dipl.-Ing.
More informationSpecial PRG Lecture No. 2. Professor David Brailsford Special PRG Lecture: Arrays
Special PRG Lecture No. 2 Professor David Brailsford (dfb@cs.nott.ac.uk) School of Computer Science University of Nottingham Special PRG Lecture: Arrays Page 1 The need for arrays Suppose we want to write
More informationA First Book of ANSI C Fourth Edition. Chapter 8 Arrays
A First Book of ANSI C Fourth Edition Chapter 8 Arrays One-Dimensional Arrays Array Initialization Objectives Arrays as Function Arguments Case Study: Computing Averages and Standard Deviations Two-Dimensional
More informationLesson 7. Reading and Writing a.k.a. Input and Output
Lesson 7 Reading and Writing a.k.a. Input and Output Escape sequences for printf strings Source: http://en.wikipedia.org/wiki/escape_sequences_in_c Escape sequences for printf strings Why do we need escape
More informationAPSC 160 Review Part 2
APSC 160 Review Part 2 Arrays September 11, 2017 Hassan Khosravi / Geoffrey Tien 1 Arrays A collection of data elements of the same type Stored in consecutive memory locations and each element referenced
More informationPrinciples of Programming. Chapter 6: Arrays
Chapter 6: Arrays In this chapter, you will learn about Introduction to Array Array declaration Array initialization Assigning values to array elements Reading values from array elements Simple Searching
More informationComputers Programming Course 12. Iulian Năstac
Computers Programming Course 12 Iulian Năstac Recap from previous course Strings in C The character string is one of the most widely used applications that involves vectors. A string in C is an array of
More informationDarshan Institute of Engineering & Technology for Diploma Studies Unit 5
1 What is structure? How to declare a Structure? Explain with Example Structure is a collection of logically related data items of different data types grouped together under a single name. Structure is
More informationPrepared By:- Dinesh Sharma Asstt. Professor, CSE & IT Deptt. ITM Gurgaon
Data Structures &Al Algorithms Prepared By:- Dinesh Sharma Asstt. Professor, CSE & IT Deptt. ITM Gurgaon What is Data Structure Data Structure is a logical relationship existing between individual elements
More informationPointers. Pointer Variables. Chapter 11. Pointer Variables. Pointer Variables. Pointer Variables. Declaring Pointer Variables
Chapter 11 Pointers The first step in understanding pointers is visualizing what they represent at the machine level. In most modern computers, main memory is divided into bytes, with each byte capable
More informationNumerical Method (2068 Third Batch)
1. Define the types of error in numerical calculation. Derive the formula for secant method and illustrate the method by figure. There are different types of error in numerical calculation. Some of them
More informationC++ Arrays. To declare an array in C++, the programmer specifies the type of the elements and the number of elements required by an array as follows
Source: Tutorials Point C++ Arrays C++ Arrays C++ provides a data structure, the array, which stores a fixed-size, sequential collection of elements of the same type An array is used to store a collection
More informationArrays in C. Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. Indian Institute of Technology Kharagpur. Basic Concept
Arrays in C Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. Indian Institute of Technology Kharagpur 1 Basic Concept Many applications require multiple data items that have common characteristics.
More informationMatrix Multiplication
Matrix Multiplication CPS343 Parallel and High Performance Computing Spring 2013 CPS343 (Parallel and HPC) Matrix Multiplication Spring 2013 1 / 32 Outline 1 Matrix operations Importance Dense and sparse
More informationOutline Arrays Examples of array usage Passing arrays to functions 2D arrays Strings Searching arrays Next Time. C Arrays.
CS 2060 Week 5 1 Arrays Arrays Initializing arrays 2 Examples of array usage 3 Passing arrays to functions 4 2D arrays 2D arrays 5 Strings Using character arrays to store and manipulate strings 6 Searching
More informationDATA STRUCTURE : A MCQ QUESTION SET Code : RBMCQ0305
Q.1 If h is any hashing function and is used to hash n keys in to a table of size m, where n
More informationArray Initialization
Array Initialization Array declarations can specify initializations for the elements of the array: int primes[10] = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29 ; initializes primes[0] to 2, primes[1] to 3, primes[2]
More informationESC101N: Fundamentals of Computing End-sem st semester
ESC101N: Fundamentals of Computing End-sem 2010-11 1st semester Instructor: Arnab Bhattacharya 8:00-11:00am, 15th November, 2010 Instructions 1. Please write your name, roll number and section below. 2.
More informationQUIZ: loops. Write a program that prints the integers from -7 to 15 (inclusive) using: for loop while loop do...while loop
QUIZ: loops Write a program that prints the integers from -7 to 15 (inclusive) using: for loop while loop do...while loop QUIZ: loops Write a program that prints the integers from -7 to 15 using: for
More informationWorksheet 11 Multi Dimensional Array and String
Name: Student ID: Date: Worksheet 11 Multi Dimensional Array and String Objectives After completing this worksheet, you should be able to Declare multi dimensional array of elements and string variables
More informationDynamic memory allocation
Dynamic memory allocation outline Memory allocation functions Array allocation Matrix allocation Examples Memory allocation functions (#include ) malloc() Allocates a specified number of bytes
More information