Skip to main content

QuickHull and divide and conquer algorithm

Requirements:

In one place there is a treasure with diamonds. To get someone to treasure should avoid an area with
mines. We want to find, from the starting point, the shortest path to reach the treasure and does not
pass through the minefield. However, it may go scratch the minefield, practically on the mines
around the minefield.

The input will be a file in the following form (without the comments):
Integer coordinates exept the third line that is a single integer representing the number of diamonds.
8 23 //starting point
130 28//coordinates of the treasure
156 // the number of the diamonds
23 108 // the 1st mine
50 99 // 2nd mine
108 107 // 3rd mine
52 54
115 107

Write a code such that:


  1. Finding the shortest path from the initial point and print the following message. The shortest distance is 122.16872656315464 The shortest path is:(8.0,23.0) -->(56.0,23.0) --> (130.0,28.0)
  2. Among the diamonds there is one fake that weighs less than the others (all the other diamonds have exactly the same weight). We have at our disposal a weighing scale (like the one in the image)

Write code that calculates the minimum number of weightings, in order to find the fake diamond. It
must print the following message.

Number of weightings: 5
Instructions
  • Write code in Java 1.7 or 1.8. The only input argument must be the input file.
  • If you use any free code from the internet it should be noted specific.
  • The complexity of a) in the Middle Case it must be O(n logn) and the complexity of b)
  • must be O(n).
  • The source code must have inline comments and extended javadoc comments over every method. You should explain the reasoning of each step and make analysis of complexity.
The weighing scale can be simulated with the following

int scale() {
        Random randomGenerator = new Random();
        int x = randomGenerator.nextInt(100);
        if (x < 34) {
            return 1; // to the left
        } else if (x < 67) {
            return 0; //equal
        } else {
            return -1; // to the right
        }
    }


CONTACT DETAILS

For any other questions or other tasks please feel free to contact me
via email: mhassnainjamil@gmail.com
via WhatsApp: +92-324-7042178
via skype: hassnainjamil1

Comments

Popular posts from this blog

The Zoo Management System - entity relationship diagram & MS Access Database

Zoo Management System - Project Details: You are the employee of a big, worldwide working Zoo Management Company. Your company is responsible for the Zoo management. Your boss thinks it would be a great idea to store all data for each Zoo in a brand new self-developed ZOO Management System. Up to now, the ZOO management company has maps of each ZOO available. Your boss knows that you took a course in introduction on an ERP system, so he asks you if you could help designing such a system. Each ZOO must have the same organizational structure, which should look like this: Each Zoo has a Zoo-Address. Each Zoo has many visitors (Visitor Ticket Process (VTP). Many Zoo-Attractions belong to a Zoo. Module 1: Entity Relationship Diagram Design a ER (entity-relationship) diagram for your ZOO Management System. Use the information provided below with the entities and its attributes. Put the entities in the correct relationship to each other (organizational structure). Module 2: DB Implem...

Human Physiology by Stuart Ira Fox [PDF] (12th edition) free download

Sudoku Game Project in Java with full source code including GUI task

Introduction The purpose of the project is to try in practice the use of recursion and object-oriented program design. Please make sure to read this entire note before starting your work. Pay close attention to the sections on deadlines, deliverables, and exam rules. The problem Your task in this part of the project is to write a solver for Sudoku puzzles. Sudoku puzzles are a kind of crossword puzzles with numbers where the following two conditions have to be met: In each row or column, the nine numbers have to be from the set [1,2,3,4,5,6,7,8,9] and they must all be different.  For each of the nine non-overlapping 3x3 blocks, the nine numbers have to be from the set [1,2,3,4,5,6,7,8,9] and they ust all be different. The following two figures show a Sudoku puzzle and its solution. The input The input of your program, the Sudoku puzzles, is given in text files. More specifically, they are represented as nine lines of nine characters separated by spaces. The characters can be of two...