Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Programming Articles - Page 340 of 3366
1K+ Views
In this Golang article, we will learn how to find the minimum element in an array using linear search by using recursion and iterative method. An array is a collection of elements of the same data type, arranged in a contiguous block of memory, and accessed using an index or a subscript. Linear search is a simple search algorithm that checks every element in a list or array one by one, starting from the beginning, until a target value is found or the entire list has been searched. It is also known as sequential search. Syntax func minFind(arr []int) int ... Read More
165 Views
In this article, we will learn how to create a golang program to reverse a circular linked list using recursion and iterative method. A circular linked list is a type of linked list where the last node in the list points back to the first node, forming a loop. It could be used to implement a circular buffer or a round-robin scheduling algorithm. Syntax func reverseList(head **Node){…} The reverseList() function is used to reverse a circular linked list. It takes an argument as value to the pointer to the address of the head node. func reverseList(current, prev, head *Node) ... Read More
1K+ Views
Swift provides a method named as updateValue() method to update the value of the dictionary using a specified key. If the specified key does not exist, then this method will add that key along with its value in the dictionary. Syntax dict.updateValue(nvalue, forKey: nkey) Here, nvalue represents the new value and nkey represents the key to which we want to update or add value. If the given key exists in the dictionary, then its value is replaced by the new value. If the given key does not exist, then it will add the nkey and nvalue in the dictionary. ... Read More
1K+ Views
Swift supports a sorted() method to sort all the elements present in the given dictionary. This method sorts the key-value pairs of the dictionary according to their keys. Syntax func sorted(by:) Here, the value of by parameters are − Greater than(>) − To sort the elements into descending order. Less than(
1K+ Views
In Swift, insertion sort is a sorting technique in which the given array is virtually divided into two parts that are the sorted and the unsorted part. Then the array is searched sequentially, compares two elements from the unsorted part, and moves them into the right place in the sorted part. Using insertion sort, we can easily sort the array elements in ascending or descending order. So in this article, we will learn how to sort an array in descending order using insertion sort. Working of insertion sort Given unsorted array To sort the array in descending order, compare ... Read More
489 Views
In Swift, insertion sort is a sorting technique in which the given array is virtually divided into two parts that are the sorted and the unsorted part. Then the array is searched sequentially, compares two elements from the unsorted part, and moves them into the right place in the sorted part. Using insertion sort, we can easily sort the array elements in ascending or descending order. So in this article, we will learn how to sort an array in ascending order using insertion sort. Working of insertion sort Given unsorted array − To sort the array in ascending order, ... Read More
518 Views
To remove the last specified character from the string Swift provide a pre-defined remove(at:) function. This function removes a character from the specified position or index. Input String = “Today is cloudy day” Character = “o” Output “Today is cludy day” Where character “o” appears two times in the input string so using the remove(at:) function we removed the last appearance of the “o” character from the string. Hence the output string is “Today is cludy day”. Syntax Str.remove(at:Idx) Where Str is the input string and idx is the valid position/index of the specified character to ... Read More
3K+ Views
To convert the string into an array of characters Swift proved the following methods − Using Array() initialiser Using append() method Input String = “Cloudy day” Output Array = [“C”, “l”, “o”, “u”, “d”, “y”, “d”, “a”, “y”] Here we converted all the characters present in the input string into the array of characters. Method 1: Using Array() initialiser Swift supports an Array() initialiser which is used to convert the input string into an array of characters. Or we can say that Array() initialiser is used to create array objects. Here we use parametrised array. Syntax ... Read More
253 Views
In Swift, convert the string into an array of characters based on the specified character using the split() function. The split() function splits the given string at the specified separator and returns the result in an array. Input String = “Today is cloudy day” Character = “y” Output [“toda”, “is cloud”, “da”] Here, the string is split at character “y” and converted the split string into an array. Syntax func.split(separator:Character, maxSplits Int, ommittingEmptySequence:Bool) The split function takes the following arguments − separator − It is an element at which the split operation happens. maxSplits − ... Read More
450 Views
The Array range queries are a new interest of data structure. In this query, we have set the random element to the array and given the general query problem to solve the data structure problem efficiently. Armstrong number is the total of its digits' cubes. For example- 0, 1, 153, 370, 371, and 407 are Armstrong numbers. Let’s take an example to understand the Armstrong number Example 1 − The given number is 371 and check whether the number is Armstrong or not. 3*3*3 + 7*7*7 + 1*1*1 = 371 Hence, this is Armstrong number. Example 2 − The given ... Read More