b. Given an array containing 286 telephone area codes assigned to the United States of America as shown below, and with the aid of illustration, show how the binary search can be used to locate the area code for: i. Silicon Valley area, which is 650 ii. Alaska area Code, which is 907 and iii. North Dakota Area Code of 701

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
100%
Please help solve
b. Given an array containing 286 telephone area codes assigned to the United States of
America as shown below, and with the aid of illustration, show how the binary search
can be used to locate the area code for:
i.
Silicon Valley area, which is 650
ii.
Alaska area Code, which is 907 and
iii.
North Dakota Area Code of 701
201 202 203 205 206 207 208 209 210 212 213 214 215 216 217 218 219 224 225 228 229 231
10
1
3
4
9
11
12
13
14
15
16
17
18
19
20
21
234 239 240 248 251 252 253 254 256 260 262 267 269 270 276 281 283 301 302 303 304 305
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
307 308 309 310 312 313 314 315 316 317 318 319 320 321 323 325 330 331 334 336 337 339
54
55
44
45
46
47
48
49
50
51
52
53
56
57
58
59
60
61
62
63
64
65
347 351 352 360 361 364 385 386 401 402 404 405 406 407 408 409 410 412 413 414 415 416
76
77
66
67
68
69
70
71
72
73
74
75
78
79
80
$1
82
83
84
85
86
87
417 419 423 424 425 430 432 434 435 440| 443 445 469 470 475 478 479 480 484 501 502 503
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
504 505 507 508 509 510 512 513 515 516 517 518 520 530 540 541 551 559 561 562 563 564
120
121
110
111
112 113
114
115 116
117
118
119
122
123
124
125
126
127
128
129
130
131
567 570 571 573 574 575 580 585 586 601 602 603 605 606 607 608 609 610 612 614 615 616
133
132
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
617 618 619 620 623 626 630 631 636 641 646 650 651 660 661 662 678 682 701 702 703 704
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
706 707 708 712 713 714 715 716 717 718 719 720 724 727 731 732 734 740 754 757 760 762
186
187
176
177 178
179
180
181
182
183
184
185
188
189
190
191
192
193
194
195
196
197
763 765 769 770 772 773 774 775 779 781 785 786 801 802 803 804| 805 806 808 810 812 813
209
198
199
200
201
202
203
204
205
206
207
208
210
211
212
213
214
215
216
217
218
219
814 815 816 817 818 828 830 831 832 835 843 845 847 848 850 856 857 858 859 860 862 863
241
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
864 865 870 878 901 903 904|906 907| 908 909 910 912 913 914 915 916|917 918 919 920 925
252
242
243
244
245
246
247
248
249
250
251
253
254
255
256
257 258
259
260
261
262
263
928 931 936 937 940 941 947 949 951 952 954 956 959 970 971 972 973 978 979 980 985 989
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
Transcribed Image Text:b. Given an array containing 286 telephone area codes assigned to the United States of America as shown below, and with the aid of illustration, show how the binary search can be used to locate the area code for: i. Silicon Valley area, which is 650 ii. Alaska area Code, which is 907 and iii. North Dakota Area Code of 701 201 202 203 205 206 207 208 209 210 212 213 214 215 216 217 218 219 224 225 228 229 231 10 1 3 4 9 11 12 13 14 15 16 17 18 19 20 21 234 239 240 248 251 252 253 254 256 260 262 267 269 270 276 281 283 301 302 303 304 305 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 307 308 309 310 312 313 314 315 316 317 318 319 320 321 323 325 330 331 334 336 337 339 54 55 44 45 46 47 48 49 50 51 52 53 56 57 58 59 60 61 62 63 64 65 347 351 352 360 361 364 385 386 401 402 404 405 406 407 408 409 410 412 413 414 415 416 76 77 66 67 68 69 70 71 72 73 74 75 78 79 80 $1 82 83 84 85 86 87 417 419 423 424 425 430 432 434 435 440| 443 445 469 470 475 478 479 480 484 501 502 503 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 504 505 507 508 509 510 512 513 515 516 517 518 520 530 540 541 551 559 561 562 563 564 120 121 110 111 112 113 114 115 116 117 118 119 122 123 124 125 126 127 128 129 130 131 567 570 571 573 574 575 580 585 586 601 602 603 605 606 607 608 609 610 612 614 615 616 133 132 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 617 618 619 620 623 626 630 631 636 641 646 650 651 660 661 662 678 682 701 702 703 704 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 706 707 708 712 713 714 715 716 717 718 719 720 724 727 731 732 734 740 754 757 760 762 186 187 176 177 178 179 180 181 182 183 184 185 188 189 190 191 192 193 194 195 196 197 763 765 769 770 772 773 774 775 779 781 785 786 801 802 803 804| 805 806 808 810 812 813 209 198 199 200 201 202 203 204 205 206 207 208 210 211 212 213 214 215 216 217 218 219 814 815 816 817 818 828 830 831 832 835 843 845 847 848 850 856 857 858 859 860 862 863 241 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 864 865 870 878 901 903 904|906 907| 908 909 910 912 913 914 915 916|917 918 919 920 925 252 242 243 244 245 246 247 248 249 250 251 253 254 255 256 257 258 259 260 261 262 263 928 931 936 937 940 941 947 949 951 952 954 956 959 970 971 972 973 978 979 980 985 989 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285
Expert Solution
Part 1

search is 650

Initially, start will be 0 and end will be 285 and mid = (0+285)/2 = 142 and array[142]=602<650

So, start will be 143 and end will be 285 and mid= (143+285)/2 = 214 and array[214]=805>650

So, start will be 143 and end will be 213 and mid= (143+213)/2 = 178 and array[178]=708>650

So, start will be 143 and end will be 177 and mid= (143+177)/2 = 160 and array[160]=630<650

So, start will be 161 and end will be 177 and mid= (161+177)/2 = 169 and array[169]=662>650

So, start will be 161 and end will be 168 and mid= (161+168)/2 = 164 and array[164]=646<650

So, start will be 164 and end will be 168 and mid= (164+168)/2 = 166 and array[166]=651>650

So, start will be 164 and end will be 165 and mid= (164+165)/2 = 164 and array[164]=646<650

So, start will be 165 and end will be 165 and mid= (165+165)/2 = 165 and array[165]=650=650

 

Thus, element found

steps

Step by step

Solved in 3 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY