Question

In: Computer Science

My assignment requires the perfect hashed data structure with about 750 nodes containing information about tickets...

My assignment requires the perfect hashed data structure with about 750 nodes containing information about tickets for the event. The number of the ticket would be the key field, the information nodes will store would be section number, row number, seat number, name and date of the event and purchaser's name. I suppose I need to use HashMap or linkedHashMap for this and create an array or linked list with all these nodes. But I don't know how to create and fill so many nodes, is there any way to make it automatically and how to approach this assignment? It's java data structures and algorithms

Solutions

Expert Solution

Here is Program for Above Problem ::

import java.util.*;
import java.util.Map.Entry;
public class Node {
    private int nooftickets;
    private  int sec_no;
    private  int row_no;
    private  int seat_no;
    private  String name;
    private  String dateofevent;
    private  String purchaer_name;

    public Node(int nooftickets, int sec_no, int row_no, int seat_no, String name, String dateofevent, String purchaer_name) {
        this.nooftickets = nooftickets;
        this.sec_no = sec_no;
        this.row_no = row_no;
        this.seat_no = seat_no;
        this.name = name;
        this.dateofevent = dateofevent;
        this.purchaer_name = purchaer_name;
    }

    public Node() {
        
    }

    public int getNooftickets() {
        return nooftickets;
    }

    public void setNooftickets(int nooftickets) {
        this.nooftickets = nooftickets;
    }

    public int getSec_no() {
        return sec_no;
    }

    public void setSec_no(int sec_no) {
        this.sec_no = sec_no;
    }

    public int getRow_no() {
        return row_no;
    }

    public void setRow_no(int row_no) {
        this.row_no = row_no;
    }

    public int getSeat_no() {
        return seat_no;
    }

    public void setSeat_no(int seat_no) {
        this.seat_no = seat_no;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDateofevent() {
        return dateofevent;
    }

    public void setDateofevent(String dateofevent) {
        this.dateofevent = dateofevent;
    }

    public String getPurchaer_name() {
        return purchaer_name;
    }

    public void setPurchaer_name(String purchaer_name) {
        this.purchaer_name = purchaer_name;
    }
}

class Test
{
    public static void main(String arp[])
    {
        Scanner sc=new Scanner(System.in);
   
        HashMap<Integer, Node> h=new HashMap<Integer, Node>();
        
        for(int i=0;i<750;i++)
        {
            Node n=new Node();
            n.setNooftickets(sc.nextInt());
            n.setSec_no(sc.nextInt());
            n.setRow_no(sc.nextInt());
            n.setSeat_no(sc.nextInt());
            n.setName(sc.next());
            n.setDateofevent(sc.next());
            n.setPurchaer_name(sc.next());
            
            h.put(n.getNooftickets(),n);
        }
     Set<Integer> keys = h.keySet();
    Iterator<Integer> it = keys.iterator();
    System.out.println("----------------Information of Tickets For The Event----------------------------");
    System.out.println();
    System.out.println(" No of Tickets "+" Section No "+" Row No "+" Seat No "+" Name "+" Date of Event "+" Purchaer Name ");
    while(it.hasNext()){
      int x=it.next();
      Node p=h.get(x);
      System.out.println(p.getNooftickets()+"                 "+p.getSec_no()+"            "+p.getRow_no()+"     "+p.getSeat_no()+"       "+p.getName()+"     "+p.getDateofevent()+"     "+p.getPurchaer_name());
    } 
        
    }
}

Here is Some test cases :

INPUT (ENTER ALL 750 VALUES LIKE THIS) :

i tried with 2.

1 2 1 12 Ram 27-10-2020 Shaym
2 3 2 20 xyz 26-10-2020 abcd

Output :

----------------Information of Tickets For The Event----------------------------

 No of Tickets  Section No  Row No  Seat No  Name  Date of Event  Purchaer Name 
1                 2            1     12       Ram     27-10-2020     Shaym
2                 3            2     20       xyz     26-10-2020     abcd

Related Solutions

A maximum of 300 nodes are to be stored in a hashed data structure. Give the...
A maximum of 300 nodes are to be stored in a hashed data structure. Give the size of the primary storage area that would maximize the performance of the structure.
Perfect Competition (15) 1. What is unique about perfect competition as a market structure that sets...
Perfect Competition (15) 1. What is unique about perfect competition as a market structure that sets it apart from the other three market structures we cover in this course? How does it affect the diagrams that we use to analyze firm behavior? (4)
FINANCE ASSIGNMENT **THIS ASSIGNMENT REQUIRES THE USE OF MICROSOFT EXCEL** Refer to information page on the...
FINANCE ASSIGNMENT **THIS ASSIGNMENT REQUIRES THE USE OF MICROSOFT EXCEL** Refer to information page on the use of some finance features in Excel. Understand financial functions @PMT, @PPMT, @IPMT, @PV and @FV. See here. 1. Assume you are employed at $60,000 per year. Consider such deductions as social security, income taxes (federal, state and county) and your payment on health benefits. Do the best you can to come to grips with what is a realistic monthly take home pay. 2....
ASSUMPTION: Perfect information about the present. Buyers and sellers know everything there is to know about...
ASSUMPTION: Perfect information about the present. Buyers and sellers know everything there is to know about the goods being exchanged. Also, each is aware of the wishes of every other potential buyer and seller in the market. REALITY: The world is full of lemons-goods about which the buyer is inadequately informed. Also, people are not mind-readers, so sellers get stuck with surpluses and willing buyers are unable to find the products they want. Questions: Explain how, if the assumption is...
In this assignment you are to utilize the Node data structure provided on Blackboard. In this...
In this assignment you are to utilize the Node data structure provided on Blackboard. In this assignment you are to write a main program that implements two methods and a main method as their driver. So, only main and two methods with it. Implementation Details: Method 1: ^^^^^^^^^ Parameters and return type: Takes as parameters an array of integers, the size of the array of integer (.length is acceptable also) and it should return a Node that is supposed to...
In this assignment you are to utilize the Node data structure provided on Blackboard. In this...
In this assignment you are to utilize the Node data structure provided on Blackboard. In this assignment you are to write a main program that implements two methods and a main method as their driver. So, only main and two methods with it. Implementation Details: Method 1: ^^^^^^^^^ Parameters and return type: Takes as parameters an array of integers, the size of the array of integer (.length is acceptable also) and it should return a Node that is supposed to...
i want an introduction and summery about prestressed concrete to write in my assignment
i want an introduction and summery about prestressed concrete to write in my assignment
My SQL Data Model Delta Airlines wants to track certain information about its fleet of planes....
My SQL Data Model Delta Airlines wants to track certain information about its fleet of planes. Delta’s planes go in for servicing and checks every 6 months. These checks are conducted by trained maintenance engineers. During this process there can be one or several issues related to the plane that are identified and noted. Delta wants to track information about the planes, the issues identified with the plane and the maintenance engineer who has identified these issues. Engineers may identify...
Assignment #2 (JAVA) In assignment 1 you had used the data structure called Stack to evaluate...
Assignment #2 (JAVA) In assignment 1 you had used the data structure called Stack to evaluate arithmetic expressions by first converting the given infixed expressions to postfixed expressions, and then evaluated the post fixed expression. Repeat the exercise for this assignment (assignment 2) by using the data structure called Binary Trees. Your output must display the original expression, the postfixed expression representing the Binary tree, and the evaluated result. Please bear in mind that a given expression could result in...
This is an assignment about McDonald`s: What is the current structure of the company (org chart)?...
This is an assignment about McDonald`s: What is the current structure of the company (org chart)? What model of authority is present in the company? What communication style is present in the company? What leadership model is present in the company? What model of coaching/empowerment is present in the company?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT