Question
Hello, I would like to get help with the following algorithm, thank you in advance. For the problem, provide the following: 1) A description of
Hello, I would like to get help with the following algorithm, thank you in advance.
For the problem, provide the following: 1) A description of your algorithm in pseudo-code (well written sentences/steps are fine), 2) Proof of correctness, and 3) analysis of run time.
1. Card Flipper: You walk into a room, and see a row of n cards. Each one has a number xi written on it, where i ranges from 1 to n. However, initially all the cards are face down. Your goal is to find a local minimum: that is, a card i whose number is less than or equal to those of its neighbors, xi-1 >= xi <= xi+1. The first and last cards can also be local minima, and they only have one neighbor to compare to. There can be many local minima, but you are only responsible for finding one of them. Obviously you can solve this problem by turning over all n cards, and scanning through them. However, show that you can find such a minimum by turning over only O(log n) cards
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started