# GRID SEARCHING Novel way of Searching 2D Array

Save this PDF as:

Size: px
Start display at page:

## Transcription

1 GRID SEARCHING Novel way of Searching 2D Array Rehan Guha Institute of Engineering & Management Kolkata, India Abstract: Linear/Sequential searching is the basic search algorithm used in data structures. Linear search is used to find a particular element in a 2D array. It is not compulsory to arrange an array in any order (Ascending or Descending) as in case of 2D binary search. In this paper, I present a unique searching algorithm named Grid Search, which helps to search an unsorted 2D Array/Matrix with least time complexity and iteration. We also have compared the Grid searching algorithm with Linear Search Algorithm. We used C++ for implementation and analysis of CPU time taken by both the algorithms. Results have shown that Grid Searching Algorithm is working well for all input values and it takes lesser time than Sequential Searching in all aspects. Keywords: Matrix Searching algorithms; 2D Array Searching algorithms; 2D Array Linear Searching; 2D Array Grid Searching; Complexity Analysis; Algorithms; Searching Algorithms; 1. INTRODUCTION 2D Array or Matrix searching algorithm is a widely used and known searching algorithm. Though it is a primitive and basic searching technique, but it is widely used in different fields even today. Fields include Bio-medical image processing, Rasterization techniques, Electrooptical displays, Pixel tracing and many more. In this paper I have developed a new searching technique named Grid Searching, based on the existing limitations of the 2D array linear/sequential search algorithm. In 2D array searching an iterator 1 traverses sequentially from left to right (row major) or top to down (column major). When it encounters an element which is equal to the key 2 the search stops and the index of the element is returned, but if the key is not present in the 2D array the function will return 0, implying that the key is not found. Sequential search or linear search is the basic search algorithm used in data structures for 2D array[1] with unsorted data. 2. RELATED WORK Linear search is used to find a particular element in an array. It is not compulsory to arrange an array in any order 3 as in the case of binary search. Linear search starts by sequentially scanning the elements in the 2D array (Row major wise or Column major wise) and if the element has been found, it will display the particular element s index value in the 2D array/matrix, else it will display not found[2][3]. If we declare a 2D array of order (n X n) i.e. size of array is n 2 then we initialize the array with the value (either static or dynamic declaration of values)[4]. In that if we mention the particular element to be identified, the linear search will start to search the array from the index 0, 0. If the value is not found, then the iterator will increment the index value by 1 in the column/row index becoming (0, 1) / (1, 0) and then it will check the element in that index again. This process continues till the element has been identified in the 2D Array/Matrix. 1 It is a variable which acts as an counter variable and acts as an index for 2D array/matrix 2 The element which is to be searched in the 2D array/matrix 3 Ascending, Descending or any other sequence/series 26

2 Algorithm(s): Input: LINEAR_SEARCH (M, NUM, n) 2D array/matrix M NUM is the key which is to be searched in M n is the order of the 2D array/matrix M (n X n) i & j are the iterators and works as index of the 2D array/matrix. Pseudo Code: where, n= 1,2,3,4,5,6,7 LINEAR_SEARCH (M, NUM, n) 1. Flag 0 2. for i 0 to n-1 3. for j 0 to n-1 4. if (M[i][j] == NUM) then 5. Flag 1 6. return (i, j) 7. end if 8. next j 9. next i 10. if (Flag == 0) then 11. return end if Algorithm(s): Input: GRID_SEARCH(M, n, NUM), CHECK (M, n, i, j, NUM), RANGE (n) 2D array/matrix M NUM is the key which is to be searched in M n is the order of the 2D array/matrix M (n X n) i & j are the iterators and works as index of the 2D array/matrix. Pseudo Code: where, n= 1,2,3,4,5,6,7 RANGE (n) 1. if (n MOD 3 == 1) then 2. T (n+2) / 3 3. else if (n MOD 3 == 2) then 4. T (n+1) / 3 5. else 6. T (n) / 3 7. end if 8. return ( T * T ) Flag Checks whether the element is present or not. If function LINEAR_SEARCH finds a match with the key then it returns the index of the element(s) (there might be multiple match of elements in the 2D array/matrix). Else it returns 0 which signifies element not found. CHECK (M, n, i, j, NUM) 1. if ( ((i>=0) AND (i<n)) AND ((j>=0) AND (j<n)) AND M[i][j] == NUM ) then 2. return 1 3. end if 4. return 0 3. MODIFIED ALGORITHM (GRID SEARCHING) If we declare and initialize a 2D array of order (n X n) i.e. size of the array is n 2 and if we mention the particular element to be identified, then the grid search will start searching the array from the index 1, 1. Now considering the index, it will search its boundary like a Grid. If the element is not found in the boundary then it will search the next set of Grids according to the order of matrix. This process continues till the element has been identified. GRID_SEARCH (M, n, NUM) 1. Flag 0 2. T RANGE(n) 3. for i 1 to T 4. for j 1 to T 5. if (CHECK(M, n, i-1, j-1, 6. Flag 1 7. return(i-1, j-1) 8. end if 27

3 9. if (CHECK(M, n, i-1, j, 10. Flag return(i-1, j) 12. end if 13. if (CHECK(M, n, i, j-1, 14. Flag return(i, j-1) 16. end if 17. if (CHECK(M, n, i-1, j+1, 18. Flag return end if 21. if (CHECK(M, n, i, j, NUM)) then 22. Flag return(i, j) 24. end if 25. if (CHECK(M, n, i, j+1, 26. Flag return (i, j+1) 28. End if 29. if (CHECK(M, n, i+1, j-1, 30. Flag return(i+1, j-1) 32. End if 33. if (CHECK(M, n, i+1, j, 34. Flag return(i+1, j) 36. end if 37. if (CHECK(M, n, i+1, j+1, 38. Flag return(i+1, j+1) 40. end if 41. next (j+3) 42. next (i+3) 43. if (Flag == 0) then 44. return end if Example: If array M has 1 element only i.e. order of the array is 1(i.e. 1 X 1) and now if we search the array and the element is found then the total number of searches will equal to 1. But if the order of the nested If-Else condition is changed then the total number searches will be greater than 1 thus in turn increases the complexity of the algorithm. Flag Checks whether the element is present or not. T Holds the returned value from the function RANGE(n). If function GRID_SEARCH finds a match with the key then it returns the index of the element(s) (there might be multiple match of elements in the 2D Array/Matrix). Else it returns 0 which signifies element is not found. 4. PROOF OF CORRECTNESS FOR GRID SEARCHING To prove that an algorithm is correct, we need to show two things: (1) that the algorithm terminates, and (2) that it produces the correct output [5] [6]. 4.1 Algorithm Grid Searching terminates after a finite number of steps The variable T 4 holds a finite number according to the function RANGE(n) (refer Section 3) and the iterator variable starts from 1 and ends at T with increment of 3. If the iteration variable is greater than equal to T then the loop terminates and does not go into an infinite loop. 4.2 Algorithm Grid Searching produces correct output If the element is found then the function GRID_SEARCH returns the index value of the found element(s) as well as sets the value of Flag 3 to 1 and if the value is NOT FOUND then the function GRID_SEARCH returns 0 indicating that the element is not present in the 2D array/matrix, thus resulting to a correct output. NOTE: Here the order of nested If-Else condition is important and cannot be changed. If it is changed the result of the algorithm may vary. 4 refer to Grid Searching algorithm under Section

4 5. PERFORMANCE ANALYSIS AND COMPARISON Both the searching algorithm (Sequential Searching and Grid Searching) were implemented in C++ using GNU G++ Compiler. Both the searching algorithm was executed on machine with:- 32-bit Operating System having Intel Core i3-4005u 1.70GHz, 1.70GHz and installed memory (RAM) 4.00GB. 5.1 Analysis of the Function of both the algorithms Function of Linear/Sequential searching f(x): f(x) = x 2 + x + 1..(i) Function of Grid searching g(x): g(x) = x 2 /9 + 18x + 5..(ii) The functions are derived from their respective algorithms (refer Section 2 & 3). The function has taken the for loop(s), if-else condition(s) into consideration. The condition below is true for all the values of x greater than equal to 20 (x >= 20) according to the equation (i) and (ii), where x= 1, 2, 3, 4 g(x)>f(x)..(iii) Table 1: Analysis of Functions N Grid Searching (Proposed Algorithm ) Function Sequential Searching Function Figure 1 From the above graph (Fig. 1) we may come to a conclusion that Grid Searching function (g(x)) is highly effective with respect to Linear/Sequential searching (f(x)) when x >= 20 where x=1, 2, 3, 4, Analysis of Worst-case iteration complexity Worst-case iteration complexity measures the resources (e.g. running time, memory) that an algorithm requires in the worst-case. It gives an upper bound on the resources required by the algorithm. Thus the worst-case of an algorithm is the total number of iteration(s) required for searching an element which is not present in the 2D array/matrix, thus shows the total no. of iteration required for fulfilling a NOT FOUND condition. NOT FOUND condition is checked for the order of matrices (n X n) where n = 3, 6, 9, 12 According to equations (i) and (ii) from Section 5.1 f(x) = x 2 + x + 1..(i) (refer Section 5.1) Function of Linear/Sequential searching is f(x) And, g(x) = x 2 /9 + 18x + 5..(ii) (refer Section 5.1) Function of Grid searching is g(x) 29

5 The highest degree of both the equations is as follows: f(x) = g(x) = x 2.. (iii) Thus from equation (iii) we can conclude, The Orders of Complexity of both the equations are O(n 2 ) Therefore, Orders of complexity of both the algorithms are O(Grid Searching) = O(Sequential Searching) = O(n 2 ) But, According to the equation (i) and (ii) considering the highest degree of the equation with constants, We can say, x 2 >> x 2 /9.. (iv) x=1, 2, 3, 4 (x 2 is much greater than x 2 /9) Precisely, we can also say O(Grid Searching) = O(n 2 /9) O(Sequential Searching) = O(n 2 ) Figure 2 From the above graph (Fig. 2) we may conclude that Grid Searching is highly efficient with an increase in the order of matrix with respect to Linear/Sequential searching. Finally, Grid searching has complexity of O(n 2 /9) And Sequential searching has a complexity of O(n 2 ). The condition below is true for all the values of n where n = 1, 2, 3, 4 O(n 2 /9) << O(n 2 ) Table 2: Iteration Complexity n Order Grid Searching (Proposed Algorithm) Sequential Searching 5.3 Analysis of Worst-case Time complexity The worst-case time complexity indicates the longest running time performed by an algorithm given any input of size n (if the algorithm satisfies NOT FOUND condition then that is the longest running time of the algorithm), and thus this guarantees that the algorithm finishes on time and gives us the total worst-case time complexity. Moreover, the order of growth of the worst-case complexity is used to compare the efficiency of two algorithms. All the readings shown below are an average of 10 reading of a single NOT FOUND condition. Time is represented in msec, and NOT FOUND condition is checked for the order of matrices (n X n) where n = 3, 6, 9,

6 Table 3: Time Complexity N Order Grid Searching (Proposed Algorithm) Sequential Searching The condition below is true for all values of x (1, 2, 3 ) according to the equation (i) and (ii), g(x)<f(x)..(iii) Therefore, from equation (iii) we can conclude that Grid Searching is more efficient than Sequential Searching in case of Worst-case time complexity. 5.4 Analysis of Condition checking Condition checking is the number of conditions required to find a particular element in the matrix irrespective of the presence of the element in the matrix. All the readings shown below are obtained from a matrix of order 165x165, where all the elements are arranged in an ascending order (but for both the algorithms elements may not be arranged in any particular order (Ascending or Descending)) and elements are searched in a cubic function f(n) = n 3..(i) Where, n = 1, 2, 3, 4 in the matrix of order 165 x 165. Table 4: Condition Checking Figure 3 From the graph (Fig. 3) we obtain the logarithm values of the trend-line which is automatically generated by the Graph Analyzer from Table 3. The logarithm trend-line for linear/sequential searching f(x) is as follows:- f(x) = ln(x) (i) The logarithm trend-line for Grid searching g(x) is as follows:- g(x) = ln(x) (ii) n Element Grid Searching (Proposed Algorithm) Sequential Searching 31

7 Figure 4 So for searching unordered set of data in square matrix Grid searching is more efficient than Sequential searching. 7. FUTURE SCOPE Future scope of Grid searching Algorithm is as follows:- 1. If it can be implemented for any order of matrix (non-square matrix) with unordered set of data present in it. 2. Rasterization algorithm, Electro-optical display algorithm, Pixel tracing algorithm are some examples of algorithms which are derived from sequential searching and are widely used in different fields, but if the same algorithm can be built using Grid searching then the performance might increase. From the above graph (Fig. 4) we can come to a conclusion that there is not much deviation in between the two algorithms. So, Condition checking complexity of both the algorithms is nearly same and does not affect the total time complexity. 6. CONCLUSIONS Searching is the technique that is used to find a particular element in an array. In Grid searching and Sequential searching it is not compulsory to arrange an array in any order (Ascending or Descending) as in the case of binary search of 2D array. Result shows that Grid Searching Algorithm is working well for all input values and it is highly efficient than Sequential Searching in all of the following aspects: 1. Analysis of Functions (f(x) & g(x)) of both the algorithms 2. Worst-case iterations 3. Worst-case Time complexity of both the algorithms 4. Total no. of conditional checking Grid searching algorithm also satisfies both the proof of correctness. 8. REFERENCES [1] E. Horowitz and S. Sahni, fundamental of Data Structure Rockville, MD: Computer Science Press, [2] Knuth, D.E. The Art of Computer Programming, Vol. 3: Sorting and Searching, Addison Wesley (1997), 3rd ed., [3] Alfred V., Aho J., Horroroft, Jeffrey D.U. (2002) Data Structures and Algorithms. [4] Frank M.C. (2004) Data Abstraction and Problem Solving with C++. US: Pearson Education, Inc. [5] Cormen T.H., Leiserson C.E., Rivest R.L. and Stein C. (2003) Introduction to Algorithms MIT Press, Cambridge, MA, 2 nd edition. [6] Seymour Lipschutz (2009) Data Structure with C, Schaum Series, Tata McGraw-Hill Education. 9. ABOUT THE AUTHOR Rehan Guha is a student of Computer Application. He has already invented offline security software Data Security- Multi-layer Folder Lock with Hiding 5. His other two major works include Biometric Ticketing System 6 and Biometric Voting Machine and System. 5 Published in Patent journal issue no. 44/2014 on 31/10/14. 6 Issue no. 39/2015 on 25/09/

8 All works are under process for Patent by Intellectual Property India. 33

### IS BINARY SEARCH TECHNIQUE FASTER THAN LINEAR SEARCH TECHNIQUE?

83 IS BINARY SEARCH TECHNIQUE FASTER THAN LINEAR SEARCH TECHNIQUE? Received:03.02.10 Accepted: 2.6.10 Asagba P. O, Osaghae E. O. and Ogheneovo, E. E. Department of Computer Science, University of Port

### Analysis of Algorithms: The Non-recursive Case

Analysis of Algorithms: The Non-recursive Case Key topics: * Introduction * Generalizing Running Time * Doing a Timing Analysis * Big-Oh Notation * Big-Oh Operations * Analyzing Some Simple Programs -

### Section IV.1: Recursive Algorithms and Recursion Trees

Section IV.1: Recursive Algorithms and Recursion Trees Definition IV.1.1: A recursive algorithm is an algorithm that solves a problem by (1) reducing it to an instance of the same problem with smaller

### CMPS 102 Solutions to Homework 1

CMPS 0 Solutions to Homework Lindsay Brown, lbrown@soe.ucsc.edu September 9, 005 Problem..- p. 3 For inputs of size n insertion sort runs in 8n steps, while merge sort runs in 64n lg n steps. For which

### Algorithms 2/17/2015. Double Summations. Enough Mathematical Appetizers! Algorithms. Algorithms. Algorithm Examples. Algorithm Examples

Double Summations Table 2 in 4 th Edition: Section 1.7 5 th Edition: Section.2 6 th and 7 th Edition: Section 2.4 contains some very useful formulas for calculating sums. Enough Mathematical Appetizers!

### ODD EVEN BASED BINARY SEARCH

International Journal of Computer Engineering & Technology (IJCET) Volume 7, Issue 5, Sep Oct 206, pp. 40 55, Article ID: IJCET_07_05_006 Available online at http://www.iaeme.com/ijcet/issues.asp?jtype=ijcet&vtype=7&itype=5

### Size = ub lb + 1. Note that the size of the array = ub if lb=1.

M21: INTRODUCTION: An array is a collection of homogenous data elements (ie elements of same type) described by a single name Each element of an array is referenced by a subscripted variable enclosed in

### SEARCHING AND SORTING

SEARCHING AND SORTING Searching A basic operation in computer science Problem formulation Given: Collection (array) of values A property on values Find: a value having the property in the array Examples

### Lecture Notes on Linear Search

Lecture Notes on Linear Search 15-122: Principles of Imperative Computation Frank Pfenning Lecture 5 January 29, 2013 1 Introduction One of the fundamental and recurring problems in computer science is

### ALLIED PAPER : DISCRETE MATHEMATICS (for B.Sc. Computer Technology & B.Sc. Multimedia and Web Technology)

ALLIED PAPER : DISCRETE MATHEMATICS (for B.Sc. Computer Technology & B.Sc. Multimedia and Web Technology) Subject Description: This subject deals with discrete structures like set theory, mathematical

### AP Computer Science Java Mr. Clausen Program 9A, 9B

AP Computer Science Java Mr. Clausen Program 9A, 9B PROGRAM 9A I m_sort_of_searching (20 points now, 60 points when all parts are finished) The purpose of this project is to set up a program that will

### Data Structures and Algorithms

Data Structures and Algorithms Luciano Bononi Computer Science Engineering University of Bologna bononi@cs.unibo.it http://www.cs.unibo.it/~bononi/ Slide credits: these slides have been translated from

### AS-2261 M.Sc.(First Semester) Examination-2013 Paper -fourth Subject-Data structure with algorithm

AS-2261 M.Sc.(First Semester) Examination-2013 Paper -fourth Subject-Data structure with algorithm Time: Three Hours] [Maximum Marks: 60 Note Attempts all the questions. All carry equal marks Section A

### VALLIAMMAI ENGINEERING COLLEGE SRM NAGAR, KATTANKULATHUR 603 203 DEPARTMENT OF COMPUTER APPLICATIONS QUESTION BANK IN REVISED BLOOM S TAXONOMY

ACADEMIC YEAR: 0 7 VALLIAMMAI ENGINEERING COLLEGE SRM NAGAR, KATTANKULATHUR 0 0 SEMESTER: ODD BRANCH: MCA YEAR: I SEMESTER: I SUBJECT CODE AND NAME: MC70 Problem Solving and Programming NAME OF THE FACULTY

### CS/COE 1501 http://cs.pitt.edu/~bill/1501/

CS/COE 1501 http://cs.pitt.edu/~bill/1501/ Lecture 01 Course Introduction Meta-notes These notes are intended for use by students in CS1501 at the University of Pittsburgh. They are provided free of charge

### Binary search algorithm

Binary search algorithm Definition Search a sorted array by repeatedly dividing the search interval in half. Begin with an interval covering the whole array. If the value of the search key is less than

### Course learning outcomes

UCS130C/UCS230C COMPUTER CONCEPTS & C PROGRAMMING 4 CREDITS Hrs/Week :04 Total Hrs:48 CIE Marks:50 SEE Marks:50 Course learning outcomes At the end of the course student will be able to: 1. Identify the

### Math 2602 Finite and Linear Math Fall 14. Homework 9: Core solutions

Math 2602 Finite and Linear Math Fall 14 Homework 9: Core solutions Section 8.2 on page 264 problems 13b, 27a-27b. Section 8.3 on page 275 problems 1b, 8, 10a-10b, 14. Section 8.4 on page 279 problems

### In the example above, it is as though the elements are in two-dimensions such a table

2 1 3 2 4 4 5 5 6 6 7 8 9 10 11 12 13 Multiple-Dimensional Arrays Elements of arrays may have more than one index, i.e. In example above, it is as though elements are in two-dimensions such a table with

### Syllabus for Computer Science. Proposed scheme for B.Sc Programme under Choice Based Credit System

Syllabus for Computer Science Proposed scheme for B.Sc Programme under Choice Based Credit System SEMESTER - I Code Course Title Course Type HPW Credits BS106 SEMESTER -I I BS 206 SEMESTER -III BS 301

### Can you design an algorithm that searches for the maximum value in the list?

The Science of Computing I Lesson 2: Searching and Sorting Living with Cyber Pillar: Algorithms Searching One of the most common tasks that is undertaken in Computer Science is the task of searching. We

### VB.NET Programming Fundamentals

Chapter 3 Objectives Programming Fundamentals In this chapter, you will: Learn about the programming language Write a module definition Use variables and data types Compute with Write decision-making statements

### IMPROVING PERFORMANCE OF RANDOMIZED SIGNATURE SORT USING HASHING AND BITWISE OPERATORS

Volume 2, No. 3, March 2011 Journal of Global Research in Computer Science RESEARCH PAPER Available Online at www.jgrcs.info IMPROVING PERFORMANCE OF RANDOMIZED SIGNATURE SORT USING HASHING AND BITWISE

### Bidirectional Linear Search Algorithm and Its Comparative Analysis with Linear Search Algorithm

Available Online at www.ijcsmc.com International Journal of Computer Science and Mobile Computing A Monthly Journal of Computer Science and Information Technology IJCSMC, Vol. 4, Issue. 12, December 2015,

### Pseudo code Tutorial and Exercises Teacher s Version

Pseudo code Tutorial and Exercises Teacher s Version Pseudo-code is an informal way to express the design of a computer program or an algorithm in 1.45. The aim is to get the idea quickly and also easy

### Fast Sequential Summation Algorithms Using Augmented Data Structures

Fast Sequential Summation Algorithms Using Augmented Data Structures Vadim Stadnik vadim.stadnik@gmail.com Abstract This paper provides an introduction to the design of augmented data structures that offer

### Parallel Ray Tracing using MPI: A Dynamic Load-balancing Approach

Parallel Ray Tracing using MPI: A Dynamic Load-balancing Approach S. M. Ashraful Kadir 1 and Tazrian Khan 2 1 Scientific Computing, Royal Institute of Technology (KTH), Stockholm, Sweden smakadir@csc.kth.se,

### Automated Model Based Testing for an Web Applications

Automated Model Based Testing for an Web Applications Agasarpa Mounica, Lokanadham Naidu Vadlamudi Abstract- As the development of web applications plays a major role in our day-to-day life. Modeling the

### Department of Computer Science, University of Agriculture, Abeokuta, Nigeria

The Usefulness of Multilevel Hash Tables with Multiple Hash Functions in Large Databases A.T. Akinwale and F.T. Ibharalu Department of Computer Science, University of Agriculture, Abeokuta, Nigeria atakinwale@yahoo.com

### Efficiency of algorithms. Algorithms. Efficiency of algorithms. Binary search and linear search. Best, worst and average case.

Algorithms Efficiency of algorithms Computational resources: time and space Best, worst and average case performance How to compare algorithms: machine-independent measure of efficiency Growth rate Complexity

### Interval Pseudo-Inverse Matrices and Interval Greville Algorithm

Interval Pseudo-Inverse Matrices and Interval Greville Algorithm P V Saraev Lipetsk State Technical University, Lipetsk, Russia psaraev@yandexru Abstract This paper investigates interval pseudo-inverse

### I PUC - Computer Science. Practical s Syllabus. Contents

I PUC - Computer Science Practical s Syllabus Contents Topics 1 Overview Of a Computer 1.1 Introduction 1.2 Functional Components of a computer (Working of each unit) 1.3 Evolution Of Computers 1.4 Generations

### Skip List Data Structure Based New Searching Algorithm and Its Applications: Priority Search

Skip List Data Structure Based New Searching Algorithm and Its Applications: Priority Search Mustafa Aksu Department of Computer Technologies Vocational School of Technical Sciences, Sutcu Imam University

### Chapter 6 Quantum Computing Based Software Testing Strategy (QCSTS)

Chapter 6 Quantum Computing Based Software Testing Strategy (QCSTS) 6.1 Introduction Software testing is a dual purpose process that reveals defects and is used to evaluate quality attributes of the software,

### CSC 180 H1F Algorithm Runtime Analysis Lecture Notes Fall 2015

1 Introduction These notes introduce basic runtime analysis of algorithms. We would like to be able to tell if a given algorithm is time-efficient, and to be able to compare different algorithms. 2 Linear

### Linear Dependence Tests

Linear Dependence Tests The book omits a few key tests for checking the linear dependence of vectors. These short notes discuss these tests, as well as the reasoning behind them. Our first test checks

### Algorithm Analysis [2]: if-else statements, recursive algorithms. COSC 2011, Winter 2004, Section N Instructor: N. Vlajic

1 Algorithm Analysis []: if-else statements, recursive algorithms COSC 011, Winter 004, Section N Instructor: N. Vlajic Algorithm Analysis for-loop Running Time The running time of a simple loop for (int

### 1. LINEAR EQUATIONS. A linear equation in n unknowns x 1, x 2,, x n is an equation of the form

1. LINEAR EQUATIONS A linear equation in n unknowns x 1, x 2,, x n is an equation of the form a 1 x 1 + a 2 x 2 + + a n x n = b, where a 1, a 2,..., a n, b are given real numbers. For example, with x and

### Notes from Week 1: Algorithms for sequential prediction

CS 683 Learning, Games, and Electronic Markets Spring 2007 Notes from Week 1: Algorithms for sequential prediction Instructor: Robert Kleinberg 22-26 Jan 2007 1 Introduction In this course we will be looking

### 222 The International Arab Journal of Information Technology, Vol. 1, No. 2, July 2004 particular pixels. High pass filter and low pass filter are gen

The International Arab Journal of Information Technology, Vol. 1, No. 2, July 2004 221 A New Approach for Contrast Enhancement Using Sigmoid Function Naglaa Hassan 1&2 and Norio Akamatsu 1 1 Department

### Introduction to Search Algorithms

Chapter 9: Searching, Sorting Introduction to Search Algorithms Search: locate an item in a list (array, vector, etc.) of information Two algorithms (methods) considered here: Linear search Binary search

### Algorithms and recursion

Read: Chapter 13 from textbook Algorithms and recursion What programs implement is recipes for solving problems. These recipes are called algorithms. We have already seen (in the practice problems from

### MLR Institute of Technology

MLR Institute of Technology DUNDIGAL 500 043, HYDERABAD COMPUTER SCIENCE AND ENGINEERING Computer Programming Lab List of Experiments S.No. Program Category List of Programs 1 Operators a) Write a C program

### Lecture 3: Finding integer solutions to systems of linear equations

Lecture 3: Finding integer solutions to systems of linear equations Algorithmic Number Theory (Fall 2014) Rutgers University Swastik Kopparty Scribe: Abhishek Bhrushundi 1 Overview The goal of this lecture

### In mathematics, it is often important to get a handle on the error term of an approximation. For instance, people will write

Big O notation (with a capital letter O, not a zero), also called Landau's symbol, is a symbolism used in complexity theory, computer science, and mathematics to describe the asymptotic behavior of functions.

### Vimal P.Parmar Research Scholar, Department of Computer Science Saurashtra University, Rajkot Gujarat, INDIA

Comparing Linear Search and Binary Search Algorithms to Search an Element from a Linear List Implemented through Static Array, Dynamic Array and Linked List Vimal P.Parmar Research Scholar, Department

### DATA STRUCTURES USING C

DATA STRUCTURES USING C QUESTION BANK UNIT I 1. Define data. 2. Define Entity. 3. Define information. 4. Define Array. 5. Define data structure. 6. Give any two applications of data structures. 7. Give

### Discrete Mathematics, Chapter 3: Algorithms

Discrete Mathematics, Chapter 3: Algorithms Richard Mayr University of Edinburgh, UK Richard Mayr (University of Edinburgh, UK) Discrete Mathematics. Chapter 3 1 / 28 Outline 1 Properties of Algorithms

### Bounded Cost Algorithms for Multivalued Consensus Using Binary Consensus Instances

Bounded Cost Algorithms for Multivalued Consensus Using Binary Consensus Instances Jialin Zhang Tsinghua University zhanggl02@mails.tsinghua.edu.cn Wei Chen Microsoft Research Asia weic@microsoft.com Abstract

### Bhakta Kavi Narsinh Mehta University, Junagadh

Bhakta Kavi Narsinh Mehta University, Junagadh Draft Syllabus for B.Sc. (Computer Science) Bachelor of Science (Computer Science) (Semester - 1) Effective From June - 2016 B.Sc. (C.S.) (Semester - 1) CS-101:

### Symbol Tables. Introduction

Symbol Tables Introduction A compiler needs to collect and use information about the names appearing in the source program. This information is entered into a data structure called a symbol table. The

### CS 4310 HOMEWORK SET 1

CS 4310 HOMEWORK SET 1 PAUL MILLER Section 2.1 Exercises Exercise 2.1-1. Using Figure 2.2 as a model, illustrate the operation of INSERTION-SORT on the array A = 31, 41, 59, 26, 41, 58. Solution: Assume

### Notes on Complexity Theory Last updated: August, 2011. Lecture 1

Notes on Complexity Theory Last updated: August, 2011 Jonathan Katz Lecture 1 1 Turing Machines I assume that most students have encountered Turing machines before. (Students who have not may want to look

### def: A worst-case complexity measure estimates the time required for the most timeconsuming

Section 2.3 Complexity 2.3.1 2.3 COMPLEXITY disambiguation: In the early 1960 s, Chaitin and Kolmogorov used complexity to mean measures of complicatedness. However, most theoretical computer scientists

### Linear Programming. March 14, 2014

Linear Programming March 1, 01 Parts of this introduction to linear programming were adapted from Chapter 9 of Introduction to Algorithms, Second Edition, by Cormen, Leiserson, Rivest and Stein [1]. 1

### Homework # 3 Solutions

Homework # 3 Solutions February, 200 Solution (2.3.5). Noting that and ( + 3 x) x 8 = + 3 x) by Equation (2.3.) x 8 x 8 = + 3 8 by Equations (2.3.7) and (2.3.0) =3 x 8 6x2 + x 3 ) = 2 + 6x 2 + x 3 x 8

### Polynomial Degree and Lower Bounds in Quantum Complexity: Collision and Element Distinctness with Small Range

THEORY OF COMPUTING, Volume 1 (2005), pp. 37 46 http://theoryofcomputing.org Polynomial Degree and Lower Bounds in Quantum Complexity: Collision and Element Distinctness with Small Range Andris Ambainis

### Olumide O. Owolabi Department of Computer Science. University of Abuja, Abuja, Nigeria

Volume 6, Issue 5, May 206 ISSN: 2277 28X International Journal of Advanced Research in Computer Science and Software Engineering Research Paper Available online at: www.ijarcsse.com An Indexed Method

### Software Development (cs2500)

Software Development (cs2500) Lecture 53: Tail Recursion and Search M.R.C. van Dongen March 4, 2011 Contents 1 Outline 1 2 Tail Recursion 2 3 Search 4 4 Linear Search 5 5 Binary Search 6 6 Analysis 7 7

### Incompleteness and Artificial Intelligence

Incompleteness and Artificial Intelligence Shane Legg Dalle Molle Institute for Artificial Intelligence Galleria 2, Manno-Lugano 6928, Switzerland shane@idsia.ch 1 Introduction The implications of Gödel

### The Little Man Computer

The Little Man Computer The Little Man Computer - an instructional model of von Neuman computer architecture John von Neuman (1903-1957) and Alan Turing (1912-1954) each independently laid foundation for

### Chapter 3. if 2 a i then location: = i. Page 40

Chapter 3 1. Describe an algorithm that takes a list of n integers a 1,a 2,,a n and finds the number of integers each greater than five in the list. Ans: procedure greaterthanfive(a 1,,a n : integers)

### Outline. 1 The Searching Problem. Unsorted Arrays. 3 Sorted Arrays. LinearSearch(k)

Outline Computer Science 331 Algorithms for Searching Mike Jacobson Department of Computer Science University of Calgary Lecture #21 1 The Searching Problem 2 3 Mike Jacobson (University of Calgary) Computer

### Introduction to Java

Introduction to Java The HelloWorld program Primitive data types Assignment and arithmetic operations User input Conditional statements Looping Arrays CSA0011 Matthew Xuereb 2008 1 Java Overview A high

### Exponential Functions and Their Graphs

Exponential Functions and Their Graphs Definition of Exponential Function f ( x) a x where a > 0, a 1, and x is any real number Parent function for transformations: f(x) = b a x h + k The graph of f moves

### Lecture 12: Chain Matrix Multiplication

Lecture 12: Chain Matrix Multiplication CLRS Section 15.2 Outline of this Lecture Recalling matrix multiplication. The chain matrix multiplication problem. A dynamic programming algorithm for chain matrix

### Arrays. number: Motivation. Prof. Stewart Weiss. Software Design Lecture Notes Arrays

Motivation Suppose that we want a program that can read in a list of numbers and sort that list, or nd the largest value in that list. To be concrete about it, suppose we have 15 numbers to read in from

### Asymptotes. Definition. The vertical line x = a is called a vertical asymptote of the graph of y = f(x) if

Section 2.1: Vertical and Horizontal Asymptotes Definition. The vertical line x = a is called a vertical asymptote of the graph of y = f(x) if, lim x a f(x) =, lim x a x a x a f(x) =, or. + + Definition.

### O(n) linear time This means that the algorithm requires a number of steps proportional to the size of the task.

Time complexity : Big O notation f(n) = O(g(n)) means There are positive constants c and k such that: 0

### Theory of Computation Prof. Kamala Krithivasan Department of Computer Science and Engineering Indian Institute of Technology, Madras

Theory of Computation Prof. Kamala Krithivasan Department of Computer Science and Engineering Indian Institute of Technology, Madras Lecture No. # 31 Recursive Sets, Recursively Innumerable Sets, Encoding

### Determining the Optimal Combination of Trial Division and Fermat s Factorization Method

Determining the Optimal Combination of Trial Division and Fermat s Factorization Method Joseph C. Woodson Home School P. O. Box 55005 Tulsa, OK 74155 Abstract The process of finding the prime factorization

### Operation Count; Numerical Linear Algebra

10 Operation Count; Numerical Linear Algebra 10.1 Introduction Many computations are limited simply by the sheer number of required additions, multiplications, or function evaluations. If floating-point

### 1 Fixed Point Iteration and Contraction Mapping Theorem

1 Fixed Point Iteration and Contraction Mapping Theorem Notation: For two sets A,B we write A B iff x A = x B. So A A is true. Some people use the notation instead. 1.1 Introduction Consider a function

### LabVIEW Based Embedded Design

LabVIEW Based Embedded Design Sadia Malik Ram Rajagopal Department of Electrical and Computer Engineering University of Texas at Austin Austin, TX 78712 malik@ece.utexas.edu ram.rajagopal@ni.com Abstract

### Domain and Range. Many problems will ask you to find the domain of a function. What does this mean?

Domain and Range The domain of a function is the set of values that we are allowed to plug into our function. This set is the x values in a function such as f(x). The range of a function is the set of

### Recursion, Search, Selection. Cheng, Wei COMP June 12, Title

Recursion, Search, Selection Cheng, Wei COMP110-001 June 12, 2014 Title Today Introduction to Recursion Introduction to Search & Selection Not a major focus of the final exam But you should be able to

### Class notes Program Analysis course given by Prof. Mooly Sagiv Computer Science Department, Tel Aviv University second lecture 8/3/2007

Constant Propagation Class notes Program Analysis course given by Prof. Mooly Sagiv Computer Science Department, Tel Aviv University second lecture 8/3/2007 Osnat Minz and Mati Shomrat Introduction This

### A FPGA based Generic Architecture for Polynomial Matrix Multiplication in Image Processing

A FPGA based Generic Architecture for Polynomial Matrix Multiplication in Image Processing Prof. Dr. S. K. Shah 1, S. M. Phirke 2 Head of PG, Dept. of ETC, SKN College of Engineering, Pune, India 1 PG

### Regression Verification: Status Report

Regression Verification: Status Report Presentation by Dennis Felsing within the Projektgruppe Formale Methoden der Softwareentwicklung 2013-12-11 1/22 Introduction How to prevent regressions in software

### 4. MATRICES Matrices

4. MATRICES 170 4. Matrices 4.1. Definitions. Definition 4.1.1. A matrix is a rectangular array of numbers. A matrix with m rows and n columns is said to have dimension m n and may be represented as follows:

### The Mixed Binary Euclid Algorithm

Electronic Notes in Discrete Mathematics 35 (009) 169 176 www.elsevier.com/locate/endm The Mixed Binary Euclid Algorithm Sidi Mohamed Sedjelmaci LIPN CNRS UMR 7030 Université Paris-Nord Av. J.-B. Clément,

### Mathematics of Cryptography Modular Arithmetic, Congruence, and Matrices. A Biswas, IT, BESU SHIBPUR

Mathematics of Cryptography Modular Arithmetic, Congruence, and Matrices A Biswas, IT, BESU SHIBPUR McGraw-Hill The McGraw-Hill Companies, Inc., 2000 Set of Integers The set of integers, denoted by Z,

### DERIVATIVES AS MATRICES; CHAIN RULE

DERIVATIVES AS MATRICES; CHAIN RULE 1. Derivatives of Real-valued Functions Let s first consider functions f : R 2 R. Recall that if the partial derivatives of f exist at the point (x 0, y 0 ), then we

### the recursion-tree method

the recursion- method recurrence into a 1 recurrence into a 2 MCS 360 Lecture 39 Introduction to Data Structures Jan Verschelde, 22 November 2010 recurrence into a The for consists of two steps: 1 Guess

### Figure 1: Graphical example of a mergesort 1.

CSE 30321 Computer Architecture I Fall 2011 Lab 02: Procedure Calls in MIPS Assembly Programming and Performance Total Points: 100 points due to its complexity, this lab will weight more heavily in your

### 10CS35: Data Structures Using C

CS35: Data Structures Using C QUESTION BANK REVIEW OF STRUCTURES AND POINTERS, INTRODUCTION TO SPECIAL FEATURES OF C OBJECTIVE: Learn : Usage of structures, unions - a conventional tool for handling a

### Lecture #3. Searching, Sorting, and Algorithm Analysis

Lecture #3 Searching, Sorting, and Algorithm Analysis Topics 1 Introduction to Search Algorithms 2 Searching an Array of Objects 3 Introduction to Sorting Algorithms 4 Sorting an Array of Objects 5 Sorting

### S. Muthusundari. Research Scholar, Dept of CSE, Sathyabama University Chennai, India e-mail: nellailath@yahoo.co.in. Dr. R. M.

A Sorting based Algorithm for the Construction of Balanced Search Tree Automatically for smaller elements and with minimum of one Rotation for Greater Elements from BST S. Muthusundari Research Scholar,

Answers to Homework 1 p. 13 1.2 3 What is the smallest value of n such that an algorithm whose running time is 100n 2 runs faster than an algorithm whose running time is 2 n on the same machine? Find the

### 8 Square matrices continued: Determinants

8 Square matrices continued: Determinants 8. Introduction Determinants give us important information about square matrices, and, as we ll soon see, are essential for the computation of eigenvalues. You

### Searching and Sorting

Linear Search Searching and Sorting Binary Search Selection Sort Insertion Sort Bubble (or Exchange) Sort Exercises Unit 27 1 Linear Search Searching is the process of determining whether or not a given

### Development of Next Generation Encryption Algorithm for Data Transmission in 3G/4G network

Available online at www.sciencedirect.com ScienceDirect Procedia Computer Science 79 (2016 ) 1044 1050 7th International Conference on Communication, Computing and Virtualization 2016 Development of Next

### 8.1. Chapter 8: Introduction to Search Algorithms. Linear Search. Linear Search - Example. Linear Search. Introduction to Search Algorithms

Chapter 8: Searching and Sorting Arrays 8.1 Introduction to Search Algorithms Introduction to Search Algorithms Search: locate an item in a list of information Two algorithms we will examine: Linear search

### DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING LESSON PLAN

ERODE SENGUNTHAR ENGINEERING COLLEGE (Approved by AICTE, New Delhi, Permanently Affiliated to Anna University - Chennai & Accredited by NAAC & National Board of Accreditation (NBA), New Delhi, Accredited

### 5: Magnitude 6: Convert to Polar 7: Convert to Rectangular

TI-NSPIRE CALCULATOR MENUS 1: Tools > 1: Define 2: Recall Definition --------------- 3: Delete Variable 4: Clear a-z 5: Clear History --------------- 6: Insert Comment 2: Number > 1: Convert to Decimal

### 12 Abstract Data Types

12 Abstract Data Types 12.1 Source: Foundations of Computer Science Cengage Learning Objectives After studying this chapter, the student should be able to: Define the concept of an abstract data type (ADT).

### Chapter 22. Working with Arrays Sorting Arrays

265 Chapter 22 Working with Arrays This chapter introduces fundamental algorithms for arrays sorting and searching and then finishes with a sample application that uses arrays. 22.1 Sorting Arrays Array