Ans: The following is the difference between Dynamic Array, Associative Array & Queue.
Dynamic Array:
- We use dynamic array when we have no idea about the size of the array during compile time and we have to allocate its size for storage during run time.
- We basically use this array when we have to store a contiguous or Sequential collection of data.
- The array indexing should be always integer type.
- To allocate size of a dynamic array, we have to use new[] operator.
int my_array [];
initial
begin
my_array = new[4]; //Allocated 4 elements
end
- To resize a dynamic array, we have to do as follows:
initial
begin
my_array = new[18](my_array); //Resize the Array and Copy
end
- To know the size of the array, we have to use size() operator.
my_array.size(); //Returns the current size of the array, my_array as an integer.
- To delete an element from a dynamic array, we have to use delete() operator.
initial
begin
my_array.delete(); //All the elements of array, my_array will be deleted.
end
Associative Array:
- It is also allocated during run time.
- This is the array, where data stored in random fashion.
- It is used when we don’t have to allocate contiguous collection of data, or data in a proper sequence or index.
- In associative array, the index itself associates the data. So it is called so.
- Indexing is not regular, can be accessed using indexing like integer or string type or any scalar.
my_array ["name"]; // “name”, Index type is a string
my_array[address]; // address, Index type is an integer (here address is an integer).
my_array[my_class]; // my_class, Index type is a class.
my_array[s_array]; // s_array, Index type is an array.
- It is better to use associative array, when size of the array is unknown & data space is random or irregular or sparse.
- Following are the methods associated with Associative array.
Eg: my_array.num()
first() — assigns the value of the first index in the Associative array to the given index variable Eg:my_array.first(i);
last() — assigns the value of the last index in the Associative array to the given index variable Eg:my_array.last(i);
next() — assigns the value of the next index in the Associative array to the given index variable Eg:my_array.next(i);
prev() — assigns the value of the previous index in the Associative array to the given index variable Eg:my_array.prev(i);
delete() — removes all the elements in the Associative array.
Eg: my_array.delete(i); If the index is specified, then the element at the specified index “i”is deleted
exists() — checks if element exists at the specified index “i” in the Associative array Eg:my_array.exists(i);
Queue:
- Queue is a variable size, ordered collection of Homogenous Data.
- It is flexible, as it is variable in size and analogous to an 1-dimensional Unpacked array that can shrink & grow automatically and can be of size zero.
- The main advantage of queue over dynamic array is that, we don’t need new[] operator to allocate storage space for a queue.
- The other advantages of queue over dynamic array is that we can manipulate the queue using various queue methods like: push, pop, delete, insert, size.
module test_example ;
int my_queue[$] = { 1, 2, 3 };
string s_queue [$] = {"first","second","third","fourth"};
string store;
initial
begin
// Use of the size() method/operator
$display("\n size() operator used");
for (int i = 0 ; i < my_queue.size(); i++ )
$display (my_queue[i]);
$display("\n\n Elements of s_queue is :");
for (int i = 0; i < s_queue.size; i++)
$write(s_queue[i]," ");
// Use of insert() method/operator
s_queue.insert(1,"next"); // Previous element 1 is now turned to element 2.
s_queue.insert(2,"somewhere");
$display("\n\n insert() operator used");
for (int i = 0; i < s_queue.size; i++)
$write(s_queue[i]," ");
// Use of delete() method/operator
s_queue.delete(1); // delete the element 1
s_queue.delete(3); // delete the element 3
$display("\n\n delete() operator used");
for (int i = 0; i < s_queue.size; i++)
$write(string_queue[i]," ");
// Use of pop_front() method/operator (it deletes the front of the queue)
store = s_queue.pop_front();
$display("\n\n pop_front() operator used");
$display(" %s",store);
for (int i = 0; i < s_queue.size; i++)
$write(s_queue[i]," ");
// Use of pop_back() method/operator (it deletes the back of the queue)
store= s_queue.pop_back();
$display("\n\n pop_back() operator used");
$display(" %s",store);
for (int i = 0; i < s_queue.size; i++)
$write(s_queue[i]," ");
// Use of push_front() and push_back() method/operator
s_queue.push_front("in-front");
s_queue.push_back("in-back");
$display("\n\n push_front() and push_back() operator used");
for (int i = 0; i < s_queue.size; i++)
$write(s_queue[i]," \n ");
end
endmodule
Result:
size() operator used
1
2
3
Elements of s_queue[$] is:
first second third fourth
insert() operator used
first next somewhere second third fourth
delete() operator used
first somewhere second fourth
pop_front() operator used
first
somewhere second fourth
pop_back() operator used
fourth
somewhere second
push_front() and push_back() operator used
in-front
somewhere
second
in-back
ugg sale
ReplyDeletechristian louboutin
nmd adidas
buffalo bills jerseys
ralph lauren outlet
oklahoma city thunder
gucci handbags
air huarache
coach outlet
new york knicks
Support For AVG Retail Enrollment With the development of the digital world, online protection is crucial. It is extremely important to protect your PCs, Mac, computers as well as mobile devices and tablets with avg activation code.
ReplyDeleteGet Started with www.norton.com/setup in order to Secure Your Devices in Simple Steps. Norton is an anti-virus, anti-malware software product. Which stops virus entering in your device at very initial level. It rapidly scans virus, spyware and worms and perform action against it.
ReplyDeletethanks have been given the opportunity to comment. Hopefully what you provided is useful for all those who need them. Visit my website if you want to know more about. really nie to read.
ReplyDeleteAi & Artificial Intelligence Course in Chennai
PHP Training in Chennai
Ethical Hacking Course in Chennai Blue Prism Training in Chennai
UiPath Training in Chennai
This has a bearing on the potency of your system. It provides you with the foremost effective cleansing facility for temporary and unwanted info and folders. MyCleanPc Free
ReplyDeleteNear is the dominant opinion which offers an expression since wherever over Google Ground app crash. 3D Territory expressions in what way the ordinary structures of elevations. Google Earth Pro Free License
ReplyDeleteLooks at to having your own sister. A connection and someone with whom you'll share your young life memories and educational encounters. Happy Sisters Day Quotes
ReplyDeleteKocaeli
ReplyDeleteDenizli
Bartın
Kocaeli
Adana
1TLK
bitlis
ReplyDeletesakarya
van
tunceli
ankara
4FE1PY
ankara parça eşya taşıma
ReplyDeletetakipçi satın al
antalya rent a car
antalya rent a car
ankara parça eşya taşıma
1YY
43EB8
ReplyDeleteBinance Güvenilir mi
Sonm Coin Hangi Borsada
Yenimahalle Fayans Ustası
Samsun Lojistik
Antep Lojistik
Urfa Şehirler Arası Nakliyat
Antep Parça Eşya Taşıma
Dxgm Coin Hangi Borsada
Şırnak Şehir İçi Nakliyat
0972F
ReplyDeletebinance %20 referans kodu
27974
ReplyDeletetokat mobil sohbet bedava
karaman rastgele görüntülü sohbet
ücretsiz sohbet uygulaması
niğde telefonda canlı sohbet
ordu görüntülü sohbet kızlarla
zonguldak sesli sohbet sitesi
erzincan kadınlarla rastgele sohbet
görüntülü sohbet ücretsiz
siirt sohbet siteleri
5E7C7
ReplyDeletekayseri sesli görüntülü sohbet
bitlis görüntülü sohbet sitesi
çanakkale rastgele görüntülü sohbet
görüntülü sohbet odaları
ankara en iyi görüntülü sohbet uygulamaları
Ankara Sohbet Uygulamaları
izmir kadınlarla rastgele sohbet
Bayburt Random Görüntülü Sohbet
afyon sesli sohbet siteler
12D0C
ReplyDeletetunceli sesli sohbet
Diyarbakır Bedava Sohbet Odaları
balıkesir mobil sohbet bedava
Mardin Ücretsiz Sohbet Uygulamaları
görüntülü sohbet kızlarla
adana ücretsiz sohbet
aksaray parasız görüntülü sohbet
izmir bedava görüntülü sohbet sitesi
adıyaman tamamen ücretsiz sohbet siteleri
93FF0
ReplyDeleteAlyattes Coin Hangi Borsada
Threads Beğeni Satın Al
Binance Referans Kodu
Mexc Borsası Kimin
Twitter Takipçi Satın Al
Okex Borsası Güvenilir mi
Kripto Para Nasıl Alınır
Binance Borsası Güvenilir mi
Yeni Çıkacak Coin Nasıl Alınır
CC07A
ReplyDeleteCoin Üretme
Mexc Borsası Kimin
Onlyfans Beğeni Hilesi
Clubhouse Takipçi Hilesi
Omlira Coin Hangi Borsada
Kripto Para Çıkarma Siteleri
Referans Kimliği Nedir
Coin Madenciliği Siteleri
Binance Hesap Açma
9C1E2
ReplyDeleteInstagram Beğeni Hilesi
Bitranium Coin Hangi Borsada
Soundcloud Reposts Hilesi
Soundcloud Reposts Satın Al
Onlyfans Beğeni Hilesi
Expanse Coin Hangi Borsada
Threads Yeniden Paylaş Hilesi
Facebook Takipçi Hilesi
Parasız Görüntülü Sohbet
83E6C
ReplyDeletekripto para nereden alınır
bitrue
kraken
kripto telegram grupları
binance
kızlarla canlı sohbet
mobil proxy 4g
bitexen
mobil 4g proxy
E244F
ReplyDeleteyabancı dizi önerileri
Google Adwords Hesap Satışı & Alışı
Tiktok Hesap Satın Al
Youtube İzlenme
Footer Link
SEO Ajansı
film önerileri
Logo Tasarım
Tiktok Takipçi Satın Al
0230C
ReplyDeleteKitap Önerileri
Toptan Ürünler
netflix film önerileri
Tanıtım Yazısı
MMORPG Oyunlar
seo nedir
metin2 pvp serverler
Google Adsense Forum
dizi önerileri
B9060
ReplyDeleteRvn Coin Yorum
Dash Coin Yorum
Dot Coin Yorum
Bitcoin Son Dakika
Wbtc Coin Yorum
Imx Coin Yorum
Lto Coin Yorum
Arb Coin Yorum
BTC Yorum
7584C10835
ReplyDeletewhatsapp show siteleri
91D3E409B1
ReplyDeletecam şov
görüntülü show
themra macun
bayan azdırıcı damla
sertleştirici
geciktirici
whatsapp görüntülü show güvenilir
yapay kızlık zarı
telegram görüntülü şov
2F1E7C8D27
ReplyDeleteperformans arttırıcı
green temptation
viagra
lifta
degra
canli cam show
ücretli show
vega
whatsapp görüntülü şov
460F3E1C7E
ReplyDeletethemra macun
vega
yapay kızlık zarı
ücretli şov
whatsapp görüntülü show güvenilir
cobra vega
canli web cam show
whatsapp ücretli show
degra 100 mg
E2476A67EE
ReplyDeletecobra vega
geciktirici jel
ücretli show
vigrande
sinegra 100 mg
bayan azdırıcı damla
whatsapp görüntülü şov
sildegra
cam show
69509300E4
ReplyDeleteyoutube beğeni satın al
D343AFC6D4
ReplyDeleteinstagram ucuz beğeni
1713E3D4E2
ReplyDeletesteroid satın al
skype show
görüntülü show
steroid satın al
www.ijuntaxmedikal.store
cialis