Introduction to Algorithms
Introduction to Algorithms
3rd Edition
ISBN: 9780262033848
Author: Thomas H. Cormen, Ronald L. Rivest, Charles E. Leiserson, Clifford Stein
Publisher: MIT Press
Question
Book Icon
Chapter 33, Problem 1P

a.

Program Plan Intro

To give an algorithm that takes O(n2) timeto find the convex layers of a set havingn points.

a.

Expert Solution
Check Mark

Explanation of Solution

The technique used to compute the convex hull of set Q is known as Package wrapping technique. It was given by Jarvis march.

The total running time of the algorithm is O(nh) , where h is the number of vertices of CH (Q).

And if there are K convex layers and the Introduction to Algorithms, Chapter 33, Problem 1P layer contains li points, the total running time is

  O(nl1+nl2+.+nlk)O(n2) .Since i=1Kli=n .

b.

Program Plan Intro

To prove that the time required to compute the convex layers of set having npoints is Ω(nlogn) .

b.

Expert Solution
Check Mark

Explanation of Solution

The following is the sorting problem which can be done in linear time.

  • If the numbers are given in sorted order, the convex layers can be determined in linear time.
  • Suppose there is a convex layer say A with 3 points into set Q for each A[k]:(0,0),(k,0) and (0,A[k]) .
  • Also supposeQ be withn convex layers and Qi be a triangle representation with the vertices (0,0),(n+i1,o) and (0,B[i]) .
  • Therefore, the corresponding sorted value can be obtained from each convex layer when they are converted.
  • Since, finding convex layers can be done in lower bound. The time taken to determine convex layers will be O(nlogn) and also these can be sorted in O(nlogn) time.

Hence, a convex layer takes Ω(nlogn) time.

Want to see more full solutions like this?

Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Students have asked these similar questions
Add a timer in the following code. public class GameGUI extends JPanel {    private final Labyrinth labyrinth;    private final Player player;    private final Dragon dragon;    private Timer timer;    private long elapsedTime;  public GameGUI(Labyrinth labyrinth, Player player, Dragon dragon) {        this.labyrinth = labyrinth;        this.player = player;        this.dragon = dragon;        String playerName = JOptionPane.showInputDialog("Enter your name:");        player.setName(playerName);        elapsedTime = 0;        timer = new Timer(1000, e -> {            elapsedTime++;            repaint();        });        timer.start(); }    @Override    protected void paintComponent(Graphics g) {        super.paintComponent(g);        int cellSize = Math.min(getWidth() / labyrinth.getSize(), getHeight() / labyrinth.getSize());}
Change the following code so that when player wins the game, the game continues by creating new GameGUI with the same player. However the player's starting position is same, everything else should be reseted. public static void main(String[] args) {        Labyrinth labyrinth = new Labyrinth(10);        Player player = new Player(9, 0);        Random rand = new Random();        Dragon dragon = new Dragon(rand.nextInt(10), 9);        JFrame frame = new JFrame("Labyrinth Game");        GameGUI gui = new GameGUI(labyrinth, player, dragon);         frame.setLayout(new BorderLayout());        frame.setSize(600, 600);        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);        frame.add(gui, BorderLayout.CENTER);        frame.pack();        frame.setResizable(false);        frame.setVisible(true);    } public class GameGUI extends JPanel {    private final Labyrinth labyrinth;    private final Player player;    private final Dragon dragon;    private Timer timer;    private long…
Create a menu item which restarts the game. Also add a timer, which counts the elapsed time since the start of the game level. When the restart is pressed, the restarted game should ask the player' name  (in the GameGUI constructor) and set the score of player to 0 (player.setScore(0)), and the timer should restart again. And create a logic so that if the player loses his life (checkGame if the condition is false), then save this number together with his name into two variables. And display two buttons where one quits the game altogether (System.exit(0)) and the other restarts the game. public class GameGUI extends JPanel {    private final Labyrinth labyrinth;    private final Player player;    private final Dragon dragon;     private final ImageIcon playerIcon = new ImageIcon("data/images/player.png");    private final ImageIcon dragonIcon = new ImageIcon("data/images/dragon.png");    private final ImageIcon wallIcon = new ImageIcon("data/images/wall.png");    private final ImageIcon…
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Operations Research : Applications and Algorithms
Computer Science
ISBN:9780534380588
Author:Wayne L. Winston
Publisher:Brooks Cole