- #1
rambo3131
- 18
- 0
Hi, I have a question about C.In a two dimensional array ,I will search a word (not a letter).Do i have to use pointers?
No, you can use array indexes in two nested for loops. Note that you will need to use a string comparison function (strcmp) rather than a condition like this one:rambo3131 said:Hi, I have a question about C.In a two dimensional array ,I will search a word (not a letter).Do i have to use pointers?
A two dimensional array is a data structure that stores values in a grid-like fashion, with rows and columns. It can be thought of as a table or matrix, where each element is identified by its row and column index.
To find a specific word in a two dimensional array, you can loop through each element and compare it to the target word. If a match is found, you can return the index of the element or the entire element itself.
The time complexity of finding a word in a two dimensional array is O(n^2) in the worst case scenario, where n is the length of the array. This is because you would need to iterate through each element in the array to search for the word.
Yes, you can use any programming language that supports two dimensional arrays to find a word in a two dimensional array. The approach may vary depending on the language, but the basic logic remains the same.
Yes, there are more efficient algorithms such as binary search or hash tables that can be used to find a word in a two dimensional array. These algorithms have a lower time complexity, but may require a more complex implementation.