Data structure used to implement an associative structure

Assignment Help Data Structure & Algorithms
Reference no: EM13753168

Learning Objectives

Gain some experience using dynamic data structures, which can grow and shrink at execution time.

In this lab, you will use Stacks, and Maps.

Learn to iterate through a dynamic data structures

Introduction

Reverse Polish notation (RPN) is a mathematical notation in which every operator follows all of its operands, in contrast to Polish notation, which puts the operator in the prefix position.

It is also known as postfix notation and is parenthesis-free as long as operator arities are fixed. The description "Polish" refers to the nationality of logician Jan Lukasiewicz, who invented (prefix) Polish notation in the 1920s.

In reverse Polish notation the operators follow their operands; for instance, to add 3 and 4, one would write 3 4 + rather than 3 + 4. If there are multiple operations, the operator is given immediately after its second operand; so the expression written 3 - 4 + 5 in conventional notation would be written 3 4 - 5 + in RPN: 4 is first subtracted from 3, then 5 added to it.

An advantage of RPN is that it obviates the need for parentheses that are required by infix notation. While 3 - 4 × 5 can also be written 3 - (4 × 5), that means something quite different from (3 - 4) × 5. In postfix, the former could be written 3 4 5 × -, which unambiguously means 3 (4 5 ×) - which reduces to 3 20 -; the latter could be written 3 4 - 5 × (or 5 3 4 - ×, if keeping similar formatting), which unambiguously means(3 4 -) 5 ×.

Despite the name, reverse Polish notation is not exactly the reverse of Polish notation, for the operands of non-commutative operations are still written in the conventional order (e.g. ÷ 6 3 in Polish notation and 6 3 ÷ in reverse Polish both evaluate to 2, whereas 3 6 ÷; in reverse Polish notation would evaluate to ½).Your Task

Now that we have explained the working of an RPN Calculator, it is time to make one ourselves.

We will do that by using the Stack data structure, which is already implemented in the Java libraries.

Use the push and pop functions as well as the constructor.

Implement a class Evaluator with a static class method evaluate that takes a String argument comprising an RPN expression and returns the int result.

Make sure to test your evaluator - pass a String argument to calls to evaluate to check the results.

Stats

Introduction

In computing, a hash table (such as a Java HashMap) is a data structure used to implement an associative structure that maps keys to values.

A hash table uses a hash function to compute an index into an array of buckets or slots, from which the correct value can be found.
In a well-dimensioned hash table, the average cost (number of instructions) for each lookup is independent of the number of elements stored in the table.

Many hash table designs also allow arbitrary insertions and deletions of key-value pairs, at constant average cost per operation.
In some situations, hash tables turn out to be more efficient than search trees or any other table lookup structure. For this reason, they are widely used in many kinds of computer software, particularly for associative arrays, database indexing, caches, and sets.
Here is the Java documentation

Scenario

You work for an esteemed sports news website. The big story is that the NBA is having a special all star league, in which teams are assigned randomly before each game. The winner(s) of the competition are the players who are in the most winning teams. Your team has developed a way to organize a file so that your reports come in faster than any other website.

Your Task

Implement a class Stats with a static class method wins that reads lines of input from a BufferedReader and computes winner statistics for each of the players mentioned in the input, by constructing a HashMapmapping the names of the players (String) to the number of wins (Integer) that player has accumulated, and returns the resulting HashMap.

Now, implement a static class method winner that iterates through a HashMap, such as returned by wins, returning the name of the player with the most wins (in the case of a tie, return any such player).

Make sure to test your methods.

Reference no: EM13753168

Questions Cloud

Identify an mis management issue : Consult your text, lectures, and or Google searching for MIS management issues. Once you identify an MIS management issue you are ready to get started. Do not hesitate to contact me for questions
Determine the tax basis of the furniture at the time of sale : Tom purchased and placed in service used office furniture on January 3, 2014, for $40,000. Tom's accountant depreciated the furniture using straight-line depreciation over 10 years for financial reporting purposes. The accountant also used the same d..
Important part of accounting and all business transactions : Ethics are an important part of accounting and all business transactions. Conduct research to identify a company's code of ethics. First Post: Share a link to the company's code of ethics, or if it is your own company, please attach a copy of it, as ..
Important factor that affects a firm financing mix : 1. Which of the following is the most important factor that affects a firm's financing mix?
Data structure used to implement an associative structure : In computing, a hash table (such as a Java HashMap) is a data structure used to implement an associative structure that maps keys to values.
Write a critical assessment of thearticles : Select two current, professional journal articles that areat least four pages in length. You must write a critical assessment of thearticles for this assignment. Keep in mind, the research databases found in theCSU Online Library are a great source f..
Find the investments NPV : Andre's retires in 5 years. He would have to purchase equipment costing $400,000 to equip a building and invest an additional $150,000 for inventories. Different buildings have a annual net cash inflow of about $160,000. Anders would close the buildi..
Two items of business equipment : Sissie owns two items of business equipment. They were both purchased in 2010 for $100,000, both have a seven-year recovery period, and both have an adjusted basis of $37,490. Sissie is considering selling these assets in 2014. One of them is worth $..
Uses a standard cost system : Luis Corporation uses a standard cost system in which it applies manufacturing overhead to products on basis of machine hours (MH's). The company's standard requires 4 Machine Hours for each unit produced. Luis budgets to produce 1,100 units per mont..

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Write an algorithm that converts linear measurement in feet

Write an algorithm that converts a linear measurement in feet and inches into meters. One inch is equivalent to 2.54 centimeters.

  Find the average number of bits needed to encode

Suppose that the symbols are compressed using Huffman Coding and that the most likely symbol is encoded as a 0, determine the decompressed value of the following compressed string of bits?

  For no-edge weights in the graph

And all you can find (out of the still-eligible distances) is an infinity for the minimum. So... "emergency exit" case out of the while loop (which isn''t in the pseudocode algorithm).

  Find minimum number of storage required for bfs and dfs

Assume we have problem space where there is uniform branching factor b and there is single goal node at depth m. Determine the minimum number of nodes expanded and storage required for BFS and DFS?

  Describe why a brute-force attack does not work

Explain exactly why an exhaustive key search will not succeed even though sufficient computational resources are available. This is a paradox since we know that the OTP is unconditionally secure.

  Question 1a explain the meaning of each of the following

question 1a explain the meaning of each of the following pointer declarations-i float a -0.137float pa ampaii double

  Design an adt for a two-color

Design an ADT for a two-color, double-stack ADT that consists of two stacks one "red" and one "blue" and has as its operations color-coded versions of the regular stack ADT operations.

  Write code to implement the expression

Write code to implement the expression: A= (B+C) * (D+E) on 3-, 2-, 1- and 0- address machines. In accordance with programming language practice, computing the expression should not change the values of its operands. Show all instructions.

  Consider a queue data structure

Consider a queue data structure, where the two operations of interest are enqueue (at the back of the queue) and dequeue (from the front of the queue). A queue is thus a FIFO (first in-first out) structure. Suppose we implement a queue by using tw..

  Creating code for a class called arrayqsn

Create all the code for a class called ArrayQsn. This class will contain 2-techniques. The first technique runningSumMean accepts an array of ints as a parameter, and will return the mean of the values as a double.

  Irected graph g = (v,e) in which edges that leave the source

Suppose that we are given a weighted, directed graph G = (V,E) in which edges that leave the source vertex s may have negative weights, all weights are nonnegative, and there are no negative-weight cycles. Argue that Dijkstra's algorithm correctly fi..

  Ford-fulkerson algorithm on capacities

Write code that finds a maximum flow in a directed graph, using the Ford-Fulkerson algorithm on capacities given as matrix void maximum flow(

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd