Difference Between Hub and Switch

Kiran Kumar Panigrahi
Updated on 10-Aug-2022 09:11:20

20K+ Views

Hubs are basic network devices that operate at the Physical Layer and they do not perform packet filtering or addressing function; they send the data packets to all the connected devices. Switches, on the other hand, function at the Data Link Layer to connect several devices in a network. Switches are mostly utilized to transmit data packets between various network devices such as routers and servers.Read through this article to find out more about hubs and switches and how they are different from each other.What is a Switch?A switch is essentially a piece of hardware or a device responsible for ... Read More

Difference Between GPS and Satellite Navigation System

Kiran Kumar Panigrahi
Updated on 10-Aug-2022 09:03:57

6K+ Views

GPS or Global Positioning System is a satellite-based navigation system developed in 1970 by the US Department of Defense. With time, it became a worldwide global utility and it is now used heavily from mobiles to cars for navigation purposes.Satellite Navigation System is a geospatial positioning system that employs satellites to enable autonomous positioning. It is built on a large network of artificial satellites in the medium-earth orbit that broadcast radio waves. Satellite Navigation Systems assist us in navigating unfamiliar roadways, whether by land, sea, or air.Read through this article to find out more about GPS and Satellite Navigation Systems ... Read More

Replace All Occurrences of String 'ab' with 'c' in C++

Prateek Jangid
Updated on 10-Aug-2022 09:01:33

518 Views

In this article, we will replace "AB" with "C" in the given string having upper case latin characters. The occurrences of "AB" becomes "C, " but single "A" and "B" are unaffected. Let us look at some input scenarios − Let's have a string "ABOUTME" Input: "ABOUTME" Result: COUTME We start traversing the string from index one. We then check the current and previous elements for "B" and "A, " respectively. If we find it, then we replace the last append ("A") with a "C." The worst case time complexity will occur when there is no substring “AB” ... Read More

Replace All Consonants with Nearest Vowels in a String Using C++ Program

Prateek Jangid
Updated on 10-Aug-2022 08:59:19

1K+ Views

The method is devised to replace a string of consonants with the closest vowels from the alphabet (also known as lowercase Latin letters). If two vowels are equally close, we can replace them with the first ones in these letters. Let us look at some input scenarios − Suppose we have a string such as “ebgkjasjd, ” and now we need to change all the present consonants with the nearest vowels in a string. Input = "ebgkjasjd"; Result = ebgkjasjd eaeiiauie Taking element ‘b, ’ we can replace it with ‘a’ since that is the nearest vowel. We could ... Read More

Repeatedly Search for an Element by Doubling it in C++

Prateek Jangid
Updated on 10-Aug-2022 08:56:48

398 Views

In this article, we are given an array of integers and a key. We must find the key repeatedly in the array and double it on each find in the array. We need to return the value not present in the array doing this operation. Some input scenarios to look at to understand how the method works in different cases Let's have an array [1, 2, 6, 3, 7, 4, 9], and its key is 1. Input: {1, 2, 3, 4, 5, 6}, k = 1 Result: 8 If we find 1 we double it to 2. If we ... Read More

Find Repeated Subsequence of Length 2 or More in C++

Prateek Jangid
Updated on 10-Aug-2022 08:52:17

275 Views

Given a string, find a subsequence with the length, at least two, repeated in the string. The index of the subsequence element numbers must not be in the same order. string s = "PNDPNSP"; print("Repeated subsequence of length 2 or more: ", (check(s) ? "Yes" : "No")); Let us look at few examples below to see how the method works in different cases − Example 1 − str = "PNDPNSP" Explanation − Here, the answer is true because there is a subsequence "PN, " repeated in the string. Example 2 − str = "PPND" Explanation − Here, the answer ... Read More

C++ Program to Reorder Words in Alphabetical Order

Prateek Jangid
Updated on 10-Aug-2022 08:48:38

549 Views

In this problem, a string is taken as the input and we have to sort the words present in the string in a lexicographical order. To do that, we assign an index to each word in the string (differentiated with spaces in between) starting from 1, and the output is obtained in the form of sorted index. String = {“Hello”, “World”} “Hello” = 1 “World” = 2 Since the words in the input string are already in lexicographical order, the output is printed as “1 2”. Let us look at some input/result scenarios − Assuming all the words in ... Read More

Remove Spaces from a String Using String Stream in C++

Prateek Jangid
Updated on 10-Aug-2022 08:41:07

945 Views

As the given problem says, we need to remove spaces from the string using a string stream. As the name suggests, a string stream converts a string into a stream. It works similar to cin in C++. It associates a string object that can access the string buffer in which it is stored. string s =" a for apple, b for ball"; res = solve(s); With a string buffer, we will read each word one by one and then concatenate it into a new string which will be our answer. Note − The class string stream is available ... Read More

Remove Number from Array to Form Geometric Progression Using C++

Prateek Jangid
Updated on 10-Aug-2022 08:29:25

152 Views

We are given an array of elements. We need to find whether the elements in the array are in Geometric Progression (GP) or not after removing any 1 element from the array. We can run out the possibilities and with observations to figure out that the first element is fake, or the second element is fake, or these 2 elements will give the common ratio of the array. After the common ratio is found, we can iterate on the array to see if all elements follow that rule. 2 base conditions would be to check if the first and second ... Read More

Remove Minimum Elements from Either Side in C++

Prateek Jangid
Updated on 10-Aug-2022 08:27:13

428 Views

The problem involves removing elements from any side of a list of integers in such a way that 2*min is greater than max. vector arr = {250, 10, 11, 12, 19, 200}; res = solve(arr); We can use brute force approach. We can try all possible subarrays which satisfy and find the longest one in which 2*min > max condition holds. We can also use dynamic programming approach to try all possible subarray combinations that are overkill and not required. Example  (Using Vector ADT) Suppose we have an array such as “[250, 10, 11, 12, 19, 200]”. To get ... Read More

Advertisements