For this problem, you are provided a 2D matrix of integers, data, with ROW rows and COL columns, where the values of the array are in ascending order in the following manner: each column contains values in ascending order, and the value of each data [0] [j] is greater than all data[i] [j-1] for all i. An example of data[4] [5] is provided below: 3 10 29 50 59 6 14 30 52 63 7 18 32 54 64 9 27 48 55 66 Write a function Search (int item, int data[ROW] [COL], int start_row, int end_row, int start_col, int end_col) to determine whether item exists within data between start_rowand end_row, start_col and end_col. If item exists within data, return 1; otherwise, return 0; To accomplish this efficiently, first perform a binary search in Row 0 for the item to locate its column. Then, perform a binary search in the appropriate column for the item. Suggested algorithm of search function (you are not required to follow this): Step 1: if start_row is greater than end_row OR start_col is greater than end_col, item is not within data (this is the base case) Step 2: if start_col is not the same as end_col, perform recursive binary search in Row 0 to locate the appropriate column Step 3: perform recursive binary search in the appropriate column to find item; return 1 if item is found

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

I need help with a C program

 

For this problem, you are provided a 2D matrix of integers, data, with ROW rows
and COL columns, where the values of the array are in ascending order in the
following manner: each column contains values in ascending order, and the value of
each data [0] [j] is greater than all data[i] [j-1] for all i. An example of
data[4] [5] is provided below:
3 10 29 50 59
6 14 30 52 63
7 18 32 54 64
9 27 48 55 66
Write a function
Search (int item, int data[ROW] [COL], int start_row,
int end_row, int start_col, int end_col)
to determine whether item exists within data between start_rowand
end_row, start_col and end_col. If item exists within data, return 1;
otherwise, return 0;
To accomplish this efficiently, first perform a binary search in Row 0 for the item to
locate its column. Then, perform a binary search in the appropriate column for the
item.
Suggested algorithm of search function (you are not required to follow this):
Step 1: if start_row is greater than end_row OR start_col is greater than end_col, item
is not within data (this is the base case)
Step 2: if start_col is not the same as end_col, perform recursive binary search in
Row 0 to locate the appropriate column
Step 3: perform recursive binary search in the appropriate column to find item;
return 1 if item is found
Transcribed Image Text:For this problem, you are provided a 2D matrix of integers, data, with ROW rows and COL columns, where the values of the array are in ascending order in the following manner: each column contains values in ascending order, and the value of each data [0] [j] is greater than all data[i] [j-1] for all i. An example of data[4] [5] is provided below: 3 10 29 50 59 6 14 30 52 63 7 18 32 54 64 9 27 48 55 66 Write a function Search (int item, int data[ROW] [COL], int start_row, int end_row, int start_col, int end_col) to determine whether item exists within data between start_rowand end_row, start_col and end_col. If item exists within data, return 1; otherwise, return 0; To accomplish this efficiently, first perform a binary search in Row 0 for the item to locate its column. Then, perform a binary search in the appropriate column for the item. Suggested algorithm of search function (you are not required to follow this): Step 1: if start_row is greater than end_row OR start_col is greater than end_col, item is not within data (this is the base case) Step 2: if start_col is not the same as end_col, perform recursive binary search in Row 0 to locate the appropriate column Step 3: perform recursive binary search in the appropriate column to find item; return 1 if item is found
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Structure chart
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education