-
- Notifications
You must be signed in to change notification settings - Fork 49.3k
Resizable/ Dynamic Array #7016
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resizable/ Dynamic Array #7016
Conversation
A dynamic array, growable array, resizable array, dynamic table, mutable array, or array list is a random access, variable-size list data structure that allows elements to be added or removed. Dynamic arrays overcome a limit of static arrays, which have a fixed capacity that needs to be specified at allocation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper reviewto trigger the checks for only added pull request files@algorithms-keeper review-allto trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
| @@ -0,0 +1,196 @@ | |||
| class resizable_array: | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Class names should follow the CamelCase naming convention. Please update the following name accordingly: resizable_array
other/Resizable_Array.py Outdated
| @@ -0,0 +1,196 @@ | |||
| class resizable_array: | |||
| def __init__(self,arraysize): | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please provide return type hint for the function: __init__. If the function does not return a value, please provide the type hint as: def function() -> None:
Please provide type hint for the parameter: arraysize
other/Resizable_Array.py Outdated
| self.arraysize = arraysize | ||
| self.array = [None for i in range(self.arraysize)] | ||
| self.temp =1 | ||
| def __insert(self,value): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file other/Resizable_Array.py, please provide doctest for the function __insert
Please provide return type hint for the function: __insert. If the function does not return a value, please provide the type hint as: def function() -> None:
Please provide type hint for the parameter: value
| #print(self.array) | ||
| #return self.array | ||
| | ||
| def insert_at_end(self, value): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file other/Resizable_Array.py, please provide doctest for the function insert_at_end
Please provide return type hint for the function: insert_at_end. If the function does not return a value, please provide the type hint as: def function() -> None:
Please provide type hint for the parameter: value
| #return self.array | ||
| else: | ||
| self.__insert(value) | ||
| def printarray(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file other/Resizable_Array.py, please provide doctest for the function printarray
Please provide return type hint for the function: printarray. If the function does not return a value, please provide the type hint as: def function() -> None:
other/Resizable_Array.py Outdated
| else: | ||
| print("value does not exists in Array after which you want to insert new value!") | ||
| | ||
| def shrink(self,value): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file other/Resizable_Array.py, please provide doctest for the function shrink
Please provide return type hint for the function: shrink. If the function does not return a value, please provide the type hint as: def function() -> None:
Please provide type hint for the parameter: value
| self.newarray=None | ||
| #print(self.array) | ||
| #return self.array | ||
| def maximum_value(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file other/Resizable_Array.py, please provide doctest for the function maximum_value
Please provide return type hint for the function: maximum_value. If the function does not return a value, please provide the type hint as: def function() -> None:
other/Resizable_Array.py Outdated
| for j in range(len(self.array)): | ||
| if max<self.array[j]: | ||
| max = self.array[j] | ||
| print("maximum value in array is: {}".format( max)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned in the Contributing Guidelines, please do not use printf style formatting or str.format(). Use f-string instead to be more readable and efficient.
| max = self.array[j] | ||
| print("maximum value in array is: {}".format( max)) | ||
| return max | ||
| def minimum_value(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file other/Resizable_Array.py, please provide doctest for the function minimum_value
Please provide return type hint for the function: minimum_value. If the function does not return a value, please provide the type hint as: def function() -> None:
other/Resizable_Array.py Outdated
| for j in range(len(self.array)): | ||
| if min>self.array[j]: | ||
| min = self.array[j] | ||
| print("minimum value in array is: {}".format(min)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned in the Contributing Guidelines, please do not use printf style formatting or str.format(). Use f-string instead to be more readable and efficient.
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper reviewto trigger the checks for only added pull request files@algorithms-keeper review-allto trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
| @@ -0,0 +1,202 @@ | |||
| class resizable_array: | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Class names should follow the CamelCase naming convention. Please update the following name accordingly: resizable_array
| @@ -0,0 +1,202 @@ | |||
| class resizable_array: | |||
| def __init__(self, arraysize): | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please provide return type hint for the function: __init__. If the function does not return a value, please provide the type hint as: def function() -> None:
Please provide type hint for the parameter: arraysize
| self.array = [None for i in range(self.arraysize)] | ||
| self.temp = 1 | ||
| | ||
| def __insert(self, value): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file other/Resizable_Array.py, please provide doctest for the function __insert
Please provide return type hint for the function: __insert. If the function does not return a value, please provide the type hint as: def function() -> None:
Please provide type hint for the parameter: value
| # print(self.array) | ||
| # return self.array | ||
| | ||
| def insert_at_end(self, value): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file other/Resizable_Array.py, please provide doctest for the function insert_at_end
Please provide return type hint for the function: insert_at_end. If the function does not return a value, please provide the type hint as: def function() -> None:
Please provide type hint for the parameter: value
| else: | ||
| self.__insert(value) | ||
| | ||
| def printarray(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file other/Resizable_Array.py, please provide doctest for the function printarray
Please provide return type hint for the function: printarray. If the function does not return a value, please provide the type hint as: def function() -> None:
| # print(self.array) | ||
| # return(self.array) | ||
| | ||
| def delete_at_first(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file other/Resizable_Array.py, please provide doctest for the function delete_at_first
Please provide return type hint for the function: delete_at_first. If the function does not return a value, please provide the type hint as: def function() -> None:
| # print(self.array) | ||
| # return self.array | ||
| | ||
| def insert_at_middle(self, insertafter, insertedvalue): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file other/Resizable_Array.py, please provide doctest for the function insert_at_middle
Please provide return type hint for the function: insert_at_middle. If the function does not return a value, please provide the type hint as: def function() -> None:
Please provide type hint for the parameter: insertafter
Please provide type hint for the parameter: insertedvalue
| "value does not exists in Array after which you want to insert new value!" | ||
| ) | ||
| | ||
| def shrink(self, value): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file other/Resizable_Array.py, please provide doctest for the function shrink
Please provide return type hint for the function: shrink. If the function does not return a value, please provide the type hint as: def function() -> None:
Please provide type hint for the parameter: value
| # print(self.array) | ||
| # return self.array | ||
| | ||
| def maximum_value(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file other/Resizable_Array.py, please provide doctest for the function maximum_value
Please provide return type hint for the function: maximum_value. If the function does not return a value, please provide the type hint as: def function() -> None:
| print(f"maximum value in array is: {max}") | ||
| return max | ||
| | ||
| def minimum_value(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file other/Resizable_Array.py, please provide doctest for the function minimum_value
Please provide return type hint for the function: minimum_value. If the function does not return a value, please provide the type hint as: def function() -> None:
| Please read our |
Describe your change:
A dynamic array, growable array, resizable array, dynamic table, mutable array, or array list is a random access, variable-size list data structure that allows elements to be added or removed. Dynamic arrays overcome a limit of static arrays, which have a fixed capacity that needs to be specified at allocation.
Checklist:
Fixes: #{$ISSUE_NO}.