Question

In: Computer Science

1.Discuss the Associative Arrays in C# and Java, with example, mention the different operations. 2.Is the...

1.Discuss the Associative Arrays in C# and Java, with example, mention the different operations.

2.Is the size static or dynamic?

Solutions

Expert Solution

`Hey,

Note: Brother if you have any queries related the answer please do comment. I would be very happy to resolve all your queries.

Most associate arrays, whether they are called dictionaries or maps or hash, are implemented using something called a hash table, and a hash table itself is a very important and useful data structure.

In Java, It has Map interface just as List was. It defines the operations for associative arrays, while HashMap and HashTable classes are implementations of these operations based on the hash table data structure.

HashTable is better when working with multi-threaded applications, where you have different threads accessing and changing this hash table, but it will add a performance cost.

ConcurrentHashMapclass is a replacement for the older HashTable.

There is also LinkedHashMap, which use linked list to iterate over the items in the same way they were inserted.

While TreeMap class also implements the Map interface, it’s actually a RedBlackTree, which is a self-balancing binary search tree.

C# also offers HashSet class which uses the hash table as in Java, while SortedSet is the sorted version.


import java.util.Hashtable;

Hashtable<String, String> capitals = new Hashtable<String, String>();
capitals.put("United Kingdom", "London");
capitals.put("Spain", "Madrid");
capitals.put("Argentina", "Buenos Aires");

It is dynamic in nature.

Kindly revert for any queries

Thanks.


Related Solutions

1.In C++, C#, Java. Discuss string operations functions, with examples. Then make Comparison of programming languages  ...
1.In C++, C#, Java. Discuss string operations functions, with examples. Then make Comparison of programming languages   2.String and StringBuffer (C#, Java) with examples.
java by using Scite Objectives: 1. Create one-dimensional arrays and two-dimensional arrays to solve problems 2....
java by using Scite Objectives: 1. Create one-dimensional arrays and two-dimensional arrays to solve problems 2. Pass arrays to method and return an array from a method Problem 2: Find the largest value of each row of a 2D array             (filename: FindLargestValues.java) Write a method with the following header to return an array of integer values which are the largest values from each row of a 2D array of integer values public static int[] largestValues(int[][] num) For example, if...
java by using Scite Objectives: 1. Create one-dimensional arrays and two-dimensional arrays to solve problems 2....
java by using Scite Objectives: 1. Create one-dimensional arrays and two-dimensional arrays to solve problems 2. Pass arrays to method and return an array from a method Problem 1: Find the average of an array of numbers (filename: FindAverage.java) Write two overloaded methods with the following headers to find the average of an array of integer values and an array of double values: public static double average(int[] num) public static double average(double[] num) In the main method, first create an...
1) a) Give short code example of parallel arrays. b) Explain how parallel arrays work. 2)...
1) a) Give short code example of parallel arrays. b) Explain how parallel arrays work. 2) a) How would you compare two arrays to check if they have the same values? b) Assume array1 and array2 are int arrays with 10 elements in each. if(array1 == array2) What is this comparing? 3 a) Can you encounter memory violation using an array? b) If yes explain. If no, explain why not.
Java program problem 1 Come up with an idea for parallel arrays Create the arrays to...
Java program problem 1 Come up with an idea for parallel arrays Create the arrays to hold 5 items in each In the main(), load the arrays with data Then output the entire contents of the arrays Create a method called find1() and pass the 2 arrays to that method. problem 2 In the find1() method, ask the user to enter a value to search for Write logic to search the first array and then output the related data from...
How are PHP arrays different than arrays in other programming languages? Please discuss in depth.
How are PHP arrays different than arrays in other programming languages? Please discuss in depth.
C++ Given 2 int arrays that are related, sort them correspondingly. EXAMPLE: int arr1[] = {84,...
C++ Given 2 int arrays that are related, sort them correspondingly. EXAMPLE: int arr1[] = {84, 4, 30, 66, 15}; int arr2[] = {7, 5, 2, 9, 10}; SORTED ANSWER: 4 - 5 15 - 10 30 - 2 66 - 9 84 - 7 IN C++
1. Mention some example of inventory fraud in term of management fraud and employee fraud! 2....
1. Mention some example of inventory fraud in term of management fraud and employee fraud! 2. Describe with your own word, what is “kickback”? What kinds of control needed to prevent or detect kickback? 3. Mention some auditor concern regarding presentation and disclosure assertion in client inventory and cost of goods sold! 4. Explain some audit procedure to test the existence or occurrence and completeness assertions of client account payable and cash disbursement!
Explain the role of taxation in the economy. Mention the different types of taxes. Discuss challenges...
Explain the role of taxation in the economy. Mention the different types of taxes. Discuss challenges of tax collection country of your choince. 4 pages
1. Two 2-D arrays A [ ] [ ] and B [ ] [ ] are...
1. Two 2-D arrays A [ ] [ ] and B [ ] [ ] are of type boolean and represent two black and white images ( 1’s (black) and 0’s (white) ) having the same size (n x m). Implement a Boolean function to receive these two images(arrays) as an input and return true if A is the negative of B (i.e. each pixel of A is the complement of the corresponding pixel of B) and false otherwise.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT