cout << “Hello world!!””;
Ok. Don’t forget to make a project, import files and compile them
-Sortings
Source codes for : bubble, selective sorting
Array is passed to a function like a pointer, but at this time you can’t get the size of array and your try will lead to size of pointer not array. So I prefered to get the size of array and then pass it to the function as an argument.
-Strings
1- Source codes for reversing a received C-string / C++ string.
In this programs, I dealt with C-string as an array and as you know array name is a pointer to its value
And, I dealt with C++ sting which is considered as an object and I passed then to my function by reference for the clear reasons
2-Source code for counting vowels in a string.
In this program, you I see the way, if you want to and some condition over a switch-case command
3- Source codes for : Design an algorithm and write code to remove the duplicate characters in a string without using any additional buffer. NOTE: One or two additional variables are fine. An extra copy of the array is not.
In this program, I made an additional array of constant size with the size of 256 which maps number of times that a character is used in the string. Once I count number of used characters, I make the string with new arrangment
4 -A method to decide if two strings are anagrams or not.
There are two solutions for this. First, you can sort the strings with a method and then compare them. Second, check if the two strings have two identical counts for each unique char.
5-A method to replace all spaces in a string with ‘%20’.
First number of space is counted, this number multiplied by two plus older
6-Given an image represented by an NxN matrix, where each pixel in the image is 4 bytes, write a method to rotate the image by 90 degrees. Can you do this in place?
7-Write an algorithm such that if an element in an MxN matrix is 0, its entire row and column is set to 0.
8-Assume you have a method isSubstring which checks if one word is a substring of another. Given two strings, s1 and s2, write code to check if s2 is a rotation of s1 using only one call to isSubstring (i.e., “waterbottle” is a rotation of “erbottlewat”).