Jump to content
 

So I was hoping someone could help me figure out some question that i have about some binary searching in my java script class that im in. So in the picture it gives you an array with some specific numbers in it and it asks what the indexes examined and the value returned would be. So i know how to get the values returned however the indexes examined is still confusing and i dont know how to get the answer. Could someone explain how to get that answer and why.

post-191116-0-31603200-1453164735.png

CPUi7 4790k (4.0 Ghz)| MotherboardMSI Z97 Gaming-5 ATX LGA1150| RAM: 16 Gb Corsair Vengeance Pro(DDR3-1600, Red 4x4Gb)GPUEVGA GTX 980 4GB Superclocked ACX 2.0| CaseFractal Design Define R5 (Black with Window)| StorageWestern Digital Caviar Blue 1TB and Samsung 850 EVO 250 GB SSD| PSUCorsair HX750i 80+ Platinum| Display(s) Asus VG248QE 144Hz 24.0" CoolingCorsair H100i GTX| Keyboard: Corsair K95 RGB| MouseRazer Deathadder Chroma|

Link to comment
https://linustechtips.com/topic/529999-binary-search-help/
Share on other sites

Link to post
Share on other sites

 

 

Every time you pick a new midpoint in your search algorithm just print it.

Wait this was a different problem than i thought. I dont know how to get the value returned on this one because there is no 86 assigned to an index.

CPUi7 4790k (4.0 Ghz)| MotherboardMSI Z97 Gaming-5 ATX LGA1150| RAM: 16 Gb Corsair Vengeance Pro(DDR3-1600, Red 4x4Gb)GPUEVGA GTX 980 4GB Superclocked ACX 2.0| CaseFractal Design Define R5 (Black with Window)| StorageWestern Digital Caviar Blue 1TB and Samsung 850 EVO 250 GB SSD| PSUCorsair HX750i 80+ Platinum| Display(s) Asus VG248QE 144Hz 24.0" CoolingCorsair H100i GTX| Keyboard: Corsair K95 RGB| MouseRazer Deathadder Chroma|

Link to comment
https://linustechtips.com/topic/529999-binary-search-help/#findComment-7031785
Share on other sites

Link to post
Share on other sites

 

 

 

Wait this was a different problem than i thought. I dont know how to get the value returned on this one because there is no 86 assigned to an index.

 

Then it will search anyway, but it will never find 86. 

Spoiler

Corsair 400C- Intel i7 6700- Gigabyte Gaming 6- GTX 1080 Founders Ed. - Intel 530 120GB + 2xWD 1TB + Adata 610 256GB- 16GB 2400MHz G.Skill- Evga G2 650 PSU- Corsair H110- ASUS PB278Q- Dell u2412m- Logitech G710+ - Logitech g700 - Sennheiser PC350 SE/598se


Is it just me or is Grammar slowly becoming extinct on LTT? 

 

Link to comment
https://linustechtips.com/topic/529999-binary-search-help/#findComment-7031824
Share on other sites

Link to post
Share on other sites

Then it will search anyway, but it will never find 86. 

So then what would the answers be if it cant find the values?

CPUi7 4790k (4.0 Ghz)| MotherboardMSI Z97 Gaming-5 ATX LGA1150| RAM: 16 Gb Corsair Vengeance Pro(DDR3-1600, Red 4x4Gb)GPUEVGA GTX 980 4GB Superclocked ACX 2.0| CaseFractal Design Define R5 (Black with Window)| StorageWestern Digital Caviar Blue 1TB and Samsung 850 EVO 250 GB SSD| PSUCorsair HX750i 80+ Platinum| Display(s) Asus VG248QE 144Hz 24.0" CoolingCorsair H100i GTX| Keyboard: Corsair K95 RGB| MouseRazer Deathadder Chroma|

Link to comment
https://linustechtips.com/topic/529999-binary-search-help/#findComment-7031841
Share on other sites

Link to post
Share on other sites

 

 

We don't have the algorithm you went over in lecture, we don't know.

 

Wtf she never gave us an algorithm

CPUi7 4790k (4.0 Ghz)| MotherboardMSI Z97 Gaming-5 ATX LGA1150| RAM: 16 Gb Corsair Vengeance Pro(DDR3-1600, Red 4x4Gb)GPUEVGA GTX 980 4GB Superclocked ACX 2.0| CaseFractal Design Define R5 (Black with Window)| StorageWestern Digital Caviar Blue 1TB and Samsung 850 EVO 250 GB SSD| PSUCorsair HX750i 80+ Platinum| Display(s) Asus VG248QE 144Hz 24.0" CoolingCorsair H100i GTX| Keyboard: Corsair K95 RGB| MouseRazer Deathadder Chroma|

Link to comment
https://linustechtips.com/topic/529999-binary-search-help/#findComment-7031914
Share on other sites

Link to post
Share on other sites

Wtf she never gave us an algorithm

 

then it is not solvable... With those numbers you will never get a index value for "86", but you will likely get outputs for "Indexes examined" up to 13 - but that will depend on what the algorithm is exactly. Algorithm may compare 86 to 89 and stop because you have gone too far. 

Spoiler

Corsair 400C- Intel i7 6700- Gigabyte Gaming 6- GTX 1080 Founders Ed. - Intel 530 120GB + 2xWD 1TB + Adata 610 256GB- 16GB 2400MHz G.Skill- Evga G2 650 PSU- Corsair H110- ASUS PB278Q- Dell u2412m- Logitech G710+ - Logitech g700 - Sennheiser PC350 SE/598se


Is it just me or is Grammar slowly becoming extinct on LTT? 

 

Link to comment
https://linustechtips.com/topic/529999-binary-search-help/#findComment-7031933
Share on other sites

Link to post
Share on other sites

Wtf she never gave us an algorithm

 

Are you sure? The questions states "Assume that we are using the binary search algorithm shown in lecture and section." so there should be something. Maybe you missed it or simply don't remember it being shown to you. Reviewing your notes/textbook or asking someone in your class might help. If that fails to resolve the matter then talk to your teacher.

 

It's also possible that it's hasn't been covered in class yet and will be covered before the assignments due date. I've had this happen in classes before although I wouldn't take a chance.

Link to comment
https://linustechtips.com/topic/529999-binary-search-help/#findComment-7033860
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×