Skip to content

Added one more Data Structure - Arrays #111

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

Merged
merged 17 commits into from
Aug 25, 2021
Merged

Added one more Data Structure - Arrays #111

merged 17 commits into from
Aug 25, 2021

Conversation

Swastyy
Copy link
Contributor

@Swastyy Swastyy commented Jul 14, 2021

In the Data Structure folder I have added the brief explanation of arrays.

Copy link
Member

@Panquesito7 Panquesito7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Good work!

@Swastyy Swastyy requested a review from Panquesito7 July 15, 2021 08:46
Panquesito7
Panquesito7 previously approved these changes Jul 15, 2021
Copy link
Member

@Panquesito7 Panquesito7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you for your contribution! 👍 🎉
@appgurueu, would you like to review this PR? Thanks. 🙂

@Panquesito7 Panquesito7 added the approved Approved; waiting for merge label Jul 15, 2021
@Panquesito7 Panquesito7 requested a review from vbrazo July 15, 2021 19:35
@appgurueu
Copy link
Collaborator

Oddly programming language (C) specific. I'd want something more abstract: Arrays are used to represent ordered sets of elements in memory accessible through indices in O(1) constant time (usually through pointer arithmetics, as you noted, but that's implementation specific). Array size is fixed, other than, say, linked list size.

@Swastyy
Copy link
Contributor Author

Swastyy commented Jul 18, 2021

Oddly programming language (C) specific. I'd want something more abstract: Arrays are used to represent ordered sets of elements in memory accessible through indices in O(1) constant time (usually through pointer arithmetics, as you noted, but that's implementation specific). Array size is fixed, other than, say, linked list size.

Ohh then we can use vectors instead more specifically vector arrays. I mean there will not be size restriction and accessing elements using index will still be there. Moreover arrays (normal and vector both) are very commonly used by everyone. Let me know your thoughts

Copy link
Member

@raklaptudirm raklaptudirm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some suggestions to make the concept of arrays more clear and to make them more general, i.e., not oriented to a single language.

raklaptudirm
raklaptudirm previously approved these changes Jul 20, 2021
Copy link
Member

@Panquesito7 Panquesito7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there! 😄

@Swastyy Swastyy requested a review from Panquesito7 July 20, 2021 04:41
@Swastyy Swastyy dismissed stale reviews from Panquesito7, vbrazo, and raklaptudirm via 0f2a9ce July 24, 2021 15:48
@Swastyy
Copy link
Contributor Author

Swastyy commented Jul 24, 2021

I'll merge in a few days if there are no objections.

I do object. As said:

  1. Remove the comment on arrays being stored "on the stack" (what is this supposed to mean anyways? implementation specific)
  2. Remove the comment regarding memory layout in Rust

Alright. Using stack is anyways very bad.

raklaptudirm
raklaptudirm previously approved these changes Jul 25, 2021
Panquesito7
Panquesito7 previously approved these changes Jul 25, 2021
@Swastyy Swastyy requested a review from raklaptudirm July 25, 2021 18:59
raklaptudirm
raklaptudirm previously approved these changes Jul 26, 2021
@Panquesito7
Copy link
Member

@appgurueu, would you like to review? Thanks.

@appgurueu
Copy link
Collaborator

appgurueu commented Jul 30, 2021

Alright. Using stack is anyways very bad.

No it's not? A linked stack has constant time pushing and popping.

Still, the compile time remark depends on your terminology. In Golang terms, this is correct; arrays whose size is known at runtime are called slices. Array size is fixed at allocation.

@Swastyy
Copy link
Contributor Author

Swastyy commented Jul 30, 2021

Alright. Using stack is anyways very bad.

No it's not? A linked stack has constant time pushing and popping.

Still, the compile time remark depends on your terminology. In Golang terms, this is correct; arrays whose size is known at runtime are called slices. Array size is fixed at allocation.

I think we shouldn't take different languages as examples since every data structure is not same in every language in terms of declaration or working. We are creating this array file assuming that the person seeing will use it where it can be applied in the way.

@appgurueu
Copy link
Collaborator

Alright. Using stack is anyways very bad.

No it's not? A linked stack has constant time pushing and popping.
Still, the compile time remark depends on your terminology. In Golang terms, this is correct; arrays whose size is known at runtime are called slices. Array size is fixed at allocation.

I think we shouldn't take different languages as examples since every data structure is not same in every language in terms of declaration or working. We are creating this array file assuming that the person seeing will use it where it can be applied in the way.

This isn't about languages, it is about terminology. Usually, the term "array" is not used to only refer to arrays whose size is fixed at compile time. That's a Golang thing. Array size is fixed at allocation. In C for example you can do int n = runtime value; int array[n];.

@Swastyy
Copy link
Contributor Author

Swastyy commented Jul 31, 2021

This isn't about languages, it is about terminology. Usually, the term "array" is not used to only refer to arrays whose size is fixed at compile time. That's a Golang thing. Array size is fixed at allocation. In C for example you can do int n = runtime value; int array[n];.

The actual array will be allocated at runtime, using the size defined at compile time
See for reference https://stackoverflow.com/questions/26175859/is-the-size-of-an-array-determined-at-compile-time

@appgurueu
Copy link
Collaborator

This isn't about languages, it is about terminology. Usually, the term "array" is not used to only refer to arrays whose size is fixed at compile time. That's a Golang thing. Array size is fixed at allocation. In C for example you can do int n = runtime value; int array[n];.

The actual array will be allocated at runtime, using the size defined at compile time
See for reference https://stackoverflow.com/questions/26175859/is-the-size-of-an-array-determined-at-compile-time

See https://stackoverflow.com/questions/2672085/static-array-vs-dynamic-array-in-c. You're calling only static arrays arrays, but dynamic arrays are arrays too. It is important to include this distinction.

@Swastyy Swastyy dismissed stale reviews from raklaptudirm and Panquesito7 via ed53590 August 16, 2021 08:27
@Swastyy
Copy link
Contributor Author

Swastyy commented Aug 16, 2021

You're calling only static arrays arrays, but dynamic arrays are arrays too. It is important to include this distinction.

Correct. Review it once.

@vbrazo vbrazo merged commit 6966795 into TheAlgorithms:master Aug 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Approved; waiting for merge enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants