亚麻VO准备

数据结构基本问题

  1. array和linked list的区别
    https://techdifferences.com/difference-between-array-and-linked-list.html
  • 存储的内容不同:array存相同数据类型的数据元素,链表存储a collection of unordered linked elements,被称作nodes
  • 查找方式不同:array里的元素通过index查找,linkedlist里的元素必须从头查找
  • 访问速度不同:array直接查找元素,链表线性查找,慢
  • 插入和删除速度不同:链表比array快
  • size不同:array大小固定,链表是动态的,可改变size
  • memory分配时间不同:array中memory在编译的时候被分配,链表在运行的时候被分配
  • 存储方式不同:在array中,元素是连续存储的,在链表中随机存储
  • 所需memory不同:array用memory存储data和index,链表需要更多memory存储next&previous referencing elements
    如果array满了,扩容一点五倍,大概只是因为1.5这个数比较好。。。不会占用过多内存空间
  1. 二叉树遍历
  • 前序遍历(preorder traversal):根结点 —> 左子树 —> 右子树,用于复制这个树
  • 中序遍历(inorder traversal):左子树—> 根结点 —> 右子树,用于输出排序好的结果
  • 后序遍历(postorder traversal):左子树 —> 右子树 —> 根结点,用于删除
  • 层次遍历:只需按层次遍历即可
  1. queue和stack的区别和共同点
    https://techdifferences.com/difference-between-stack-and-queue.html
  • They are both non-primitive data structure
  • Stack: LIFO Queue:FIFO
  • Stack插入和删除在同一端,queue的插入和删除在两端
  • stack的操作有push和pop,queue有enqueue和dequeue
  • stack的实现比queue简单
  • queue有几种变形:circular,priority,doubly ended
  1. 什么时候用array,什么时候用arraylist,时间复杂度
  • array可包括基本类型和对象类型,arraylist智能包含对象类型
  • 当集合长度不固定时,使用arraylist,但是arraylist不支持基本数据类型,保存基本数据类型时性能不如array
  • 访问第n个数据O(1),查找数据,O(n),插入和删除是O(n)
  1. BST的性质
    https://songlee24.github.io/2015/01/13/binary-search-tree/
    二叉查找树要么是一棵空树,要么是一棵具有如下性质的非空二叉树:
  • 若左子树非空,则左子树上的所有结点的关键字值均小于根结点的关键字值

  • 若右子树非空,则右子树上的所有结点的关键字值均大于根结点的关键字值

  • 左、右子树本身也分别是一棵二叉查找树

  1. priorityqueue的基本操作的时间复杂度
    https://www.jianshu.com/p/eb9e6e413420
    优先队列不同实现的时间复杂度索引优先队列中方法的复杂度
  2. HashMap的原理
    HashMap 采用一种所谓的“Hash 算法”来决定每个元素的存储位置。当程序执行 map.put(String,Obect)方法 时,系统将调用String的 hashCode() 方法得到其 hashCode 值——每个 Java 对象都有 hashCode() 方法,都可通过该方法获得它的 hashCode 值。得到这个对象的 hashCode 值之后,系统会根据该 hashCode 值来决定该元素的存储位置
  3. HashMap如何handle collision
  • 定义:A collision will occur when two different keys have the same hashCode, which can happen because two unequal objects in Java can have the same hashCode.
  • 如何解决:
    (1) chaining:If hash code of second value also points to the same index then we replace that index value with an linked list and all values pointing to that index are stored in the linked list and actual array index points to the head of the the linked list.
    (2) open dressing:
    linear probing: This technique is used when we have more index in the table than the values to be stored. Linear probing technique works on the concept of keep incrementing until you find an empty slot.
    double hashing: If the slot at h1(k) is occupied then the second hashing function h2(k) used to increment the index.
  1. Java基础知识
  • late binding: is a mechanism by which a computer program waits until runtime to bind the name of a method being called to an actual subroutine. It is an alternative to early binding or static binding in which this process is performed at compile-time.
  • overriding: a feature that allows a subclass or child class to provide a specific implementation of a method that is already provided by one of its super-classes or parent classes. When a method in a subclass has the same name, same parameters or signature and same return type(or sub-type) as a method in its super-class, then the method in the subclass is said to override the method in the super-class.
  • overloading: allows different methods to have same name, but different signatures where signature can differ by number of input parameters or type of input parameters or both. Overloading is related to compile time (or static) polymorphism.
  • Polymorphism: the ability of an object to take on many forms. The most common use of polymorphism in OOP occurs when a parent class reference is used to refer to a child class object.
  • differences between object and class
    A class is a template for objects. A class defines object properties including a valid range of values, and a default value. A class also describes object behavior. An object is a member or an “instance” of a class. An object has a state in which all of its properties have values that you either explicitly define or that are defined by default settings.
  1. Difference between Process and Thread
  • A process is an active program i.e. a program that is under execution. It is more than the program code as it includes the program counter, process stack, registers, program code etc. Compared to this, the program code is only the text section.
  • A thread is a lightweight process that can be managed independently by a scheduler. It improves the application performance using parallelism. A thread shares information like data segment, code segment, files etc. with its peer threads while it contains its own registers, stack, counter etc.
    https://www.tutorialspoint.com/difference-between-process-and-thread
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值