4 votes 4 votes In a Network where bytes are continuously being transferred, it is required to identify the most frequently transferred byte. What would be an appropriate data structure for finding this? Linked List Array Dynamically growing Array Set DS go-ds-1 data-structures + – Arjun asked Oct 10, 2016 Arjun 781 views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
Best answer 10 votes 10 votes Byte means 8 bits. So, using an array of size 256 we can count the frequency of all possible (256) bytes and finally output the one with the maximum count. Arjun answered Oct 12, 2016 • selected Dec 24, 2017 by Hemant Parihar Arjun comment Share Follow See all 8 Comments See all 8 8 Comments reply Kapil commented Oct 13, 2016 reply Follow Share Sir, i used the logic of Count array used in a counting sort. This is not a counting sort problem, but an array same as count array can be maintained, to store count of each byte and how many times a byte is repeated, is it right ? 1 votes 1 votes smartmeet commented Nov 6, 2016 reply Follow Share but how could we know that some constant amount of bytes are being transfferd, so should not it be a 'Dynaic'? 0 votes 0 votes Hira Thakur commented Nov 8, 2016 reply Follow Share @ arjun sir can u give the valid reason for linked list & dynamic aray is not possible here??? 0 votes 0 votes ravi_ssj4 commented Feb 3, 2017 reply Follow Share @Arjun sir, how can u directly say that there is a limit of 256 bytes only ? In computer networks, we have seen that in TCP transfer, each byte is numbered via a sequence number which can be as high as 2^32-1, and if we include options we can even expand that. So, why can't the same concept be applied here also ? 0 votes 0 votes Arjun commented Feb 3, 2017 reply Follow Share It is not that we cannot use dynamic array or linked list. Question asks for "most appropriate". As long as we statically knows the size, we never need to go for a dynamic array. Also, here the question asks for identifying "byte" which is a sequence of 8 bits and in any context there are only 256 possible values for it. 1 votes 1 votes Markzuck commented Nov 17, 2018 reply Follow Share ok so sir, if size is fixed then always prefer static array over dynanmic? 0 votes 0 votes palashbehra5 commented Jan 8, 2022 reply Follow Share are we maintaining an eight-bit array, and updating it with every byte we transfer? 0 votes 0 votes jugnu1337 commented Oct 21, 2022 reply Follow Share @Arjun sir what happened if there is option of “STACK” and what is the "SET" in given option 1 votes 1 votes Please log in or register to add a comment.