Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions data_structures/list_array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ struct list {
* @param val element that will be searched
* @return index of element in the list if present else -1
*/
uint64_t BinarySearch(const std::array<uint64_t, N> &dataArr,
int64_t BinarySearch(const std::array<uint64_t, N> &dataArr,
const uint64_t &first, const uint64_t &last,
const uint64_t &val) {
// If both pointer cross each other means no element present in the list
Expand Down Expand Up @@ -77,7 +77,7 @@ struct list {
* @param val element that will be searched
* @return index of element in the list if present else -1
*/
uint64_t LinearSearch(const std::array<uint64_t, N> &dataArr,
int64_t LinearSearch(const std::array<uint64_t, N> &dataArr,
const uint64_t &val) const {
// Going through each element in the list
for (uint64_t i = 0; i < top; i++) {
Expand All @@ -94,8 +94,8 @@ struct list {
* @param val element that will be searched
* @return index of element in the list if present else -1
*/
uint64_t search(const uint64_t &val) {
uint64_t pos; // pos variable to store index value of element.
int64_t search(const uint64_t &val) {
int64_t pos; // pos variable to store index value of element.
// if list is sorted, binary search works efficiently else linear search
// is the only option
if (isSorted) {
Expand Down Expand Up @@ -181,7 +181,7 @@ struct list {
* @returns void
*/
void remove(const uint64_t &val) {
uint64_t pos = search(val); // search the index of the value
int64_t pos = search(val); // search the index of the value
// if search returns -1, element does not present in the list
if (pos == -1) {
std::cout << "\n Element does not present in the list ";
Expand Down
4 changes: 2 additions & 2 deletions data_structures/queue_using_array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ class Queue_Array {
* @param ele to be added to the end of the queue
*/
void Queue_Array::enqueue(const int16_t& ele) {
if (rear == arr.size() - 1) {
if (rear == static_cast<int>(arr.size()) - 1) {
std::cout << "\nStack is full";
} else if (front == -1 && rear == -1) {
front = 0;
rear = 0;
arr[rear] = ele;
} else if (rear < arr.size()) {
} else if (rear < static_cast<int>(arr.size())) {
++rear;
arr[rear] = ele;
}
Expand Down
6 changes: 3 additions & 3 deletions data_structures/trie_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class trie {
* @returns `false` if not found
*/
bool search(const std::shared_ptr<trie>& root, const std::string& str,
int index) {
size_t index) {
if (index == str.length()) {
if (!root->isEndofWord) {
return false;
Expand Down Expand Up @@ -104,7 +104,7 @@ class trie {
* @returns `true` if found
* @returns `false` if not found
*/
bool search(const std::string& str, int index) {
bool search(const std::string& str, size_t index) {
if (index == str.length()) {
if (!isEndofWord) {
return false;
Expand All @@ -131,7 +131,7 @@ class trie {
* @returns `true` if successful
* @returns `false` if unsuccessful
*/
bool deleteString(const std::string& str, int index) {
bool deleteString(const std::string& str, size_t index) {
if (index == str.length()) {
if (!isEndofWord) {
return false;
Expand Down