what is Associative array – the languages that have them and how it is implemented.
• Difference between regular arrays and associative arrays – implement in code.
Associative arrays are abstract data types that are supported in certain languages.These are collection of key value pairs. Associative arrays basically helps to form an assocaition between the key and the data it stores.
In a normal array elements are indexed starting from 0.In associative arrays the key could be any data type user's wants.For example :
arr={}
arr['Derrick'] = 80
arr['Ben']=90
In this example we have fromed assocaition between name of a student and the marks of the student.
Associative arrays offer faster access time as compared to linear data structure like array.
Associative arrays are supported by various languages like Perl, Python, Ruby, PHP, Lua, JavaScript,C/C++ etc.
Independent of the language associative arrys offer for the following operations in every platform add(),remove(),delete(),search().
Now let us look at the difference in implementation of a normal array and associative array in C++.
In C++ associative arrays are called map or dictionaries.In the next lines of code we'll make use of map stl to implement associative arrays.
C++ implementation of highlighting difference between array and associative array.
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
int arr[3]={80,90,100}; //this array stores the marks of the
student
cout<<arr[0]<<endl;; //print the marks of the first
student
map <string,int> m; //this is declaration of map
that stores string and integer key value pair
m["Derrick"]=80;
m["Ben"]=90;
m["Shawn"]=100;
cout<<m["Ben"]; //this is different from normal
array as we can print marks by searching
//the key inside the associative array.Hence it provides faster
searching
//than normal array
return 0;
}
what is Associative array – the languages that have them and how it is implemented. •...
Provide examples of how languages from different paradigms have implemented protocols of communication when a subprogram is called.
Arrays 1 a) What field does every array object have? b) Suppose you have this code: double[ ] temperatures = new double[12]; Write the lines of code to triple the capacity of the array
What is the difference between non-associative and associative learning? Which types of learning fall within each category?
Describe the operation of the enhanced for loop and explain why it’s especially useful with arrays. Explain when you need to implement the Comparable interface in a class you create. Describe the difference between a rectangular array and a jagged array, and explain the difference in how you create them. Describe the similarities and differences between arrays and collections. Name the two main types of collections defined by the collection framework and explain how they differ.
What does dynamic programming have in common with divide-and-conquer? What is a principal difference between them? Solve the instance 10, 25, 1, 1, 5, 1, 25, 10, 10 of the coin-row problem using the dynamic programming algorithm technique. Show the solution array and also the final output.(NO PSUEDO CODE ACTUALLY WORK IT OUT)
What is the primary difference between time-series and associative forecasting models? A. Associative models do not predict demand B. Associative models incorporate variables that might influence the quantity being forecasted C. Time-series models are only used for long-range forecasts D. Time-series models are only used for economic forecasts
using matlab
In Class Exercises 8-Arrays For the following exercises, assume an array is already populated, your job is to write a program that traverses the array. DO NOT HARD CODE the last index. In other words, you code for 1-4&6 should be able to handle the following 2 arrays: amp2 10 array1 [52, 63, 99, 71, 3.1] array2 - [99:-3: 45); For 5: wordArray1 wordArray2 ('number, 'arrays', 'indices', 'hello', finish' [number, 'different, 'finish? 1. Determine the sum of all...
MATLAB question: I have written a code to solve for a metals resitance. Here is the problem statement: Part 1 (Algorithms) – due Friday: Think about how you might solve the problem of calculating the resistance of a given group of metals depending on the type of metal, the length of the wire and the area of the wire (if given the diameter only – so you must calculate the area). Write instructions (an algorithm) for a script that behaves...
JAVA QUESTION I have an array String array [] = {"101", "010", 111"} I have an input of "000" that I want to compare to each value in the array and count how many times they Differ. So String input = "000" CODE A FUNCTION THAT ACCEPTS THE ARRAY AND THE INPUT VARIABLE AS PARAMETERS. IN THIS FUNCTION, CODE A FOR LOOP THAT COMPARES THE String input to each element of the array ,COUNTS how many time they differ for...
php
QUESTION 4 We have an associative array storing passwords of each user write PHP code to check if the password from user by POST method is wrong or right. Spassword array(user1' -12345, user?> password. user3ts helloworld. user4 For the toolbar, press ALT+F10 (PC) or ALT+FN+F10 (Mac password1234): Words:0 Path: p QUESTION S When defining an identifier in PHP you remember that ? SResult OA identifier are case senstive. So Sresult is different trom O B. Identifiers can be any...